Fix users tests and pages fixtures

This commit is contained in:
Skia 2015-12-02 17:14:47 +01:00
parent f17fb6e466
commit 50f53e7a6e
2 changed files with 16 additions and 13 deletions

View File

@ -1 +1 @@
[{"fields": {"edit_group": [], "revision": 1, "owner_group": 1, "view_group": [], "title": "TROLL", "is_locked": false, "full_name": "guy2", "parent": null, "name": "guy2", "content": "ZZZZZZZZZZZZZZZZZZZZZ"}, "pk": 1, "model": "core.page"}, {"fields": {"edit_group": [], "revision": 1, "owner_group": 3, "view_group": [], "title": "Bibou", "is_locked": false, "full_name": "guy/bibou", "parent": 4, "name": "bibou", "content": "Bibou Troll Homo\r\n"}, "pk": 2, "model": "core.page"}, {"fields": {"edit_group": [], "revision": 1, "owner_group": 1, "view_group": [], "title": "Troll", "is_locked": false, "full_name": "guy/bibou/troll", "parent": 2, "name": "troll", "content": "blbbllblbl"}, "pk": 3, "model": "core.page"}, {"fields": {"edit_group": [], "revision": 1, "owner_group": 1, "view_group": [], "title": "TROLL", "is_locked": false, "full_name": "guy", "parent": null, "name": "guy", "content": ""}, "pk": 4, "model": "core.page"}, {"fields": {"edit_group": [1], "revision": 1, "owner_group": 3, "view_group": [], "title": "Bibou", "is_locked": false, "full_name": "bibou", "parent": null, "name": "bibou", "content": ""}, "pk": 5, "model": "core.page"}, {"fields": {"edit_group": [], "revision": 1, "owner_group": 1, "view_group": [], "title": "Bibou-Guy", "is_locked": false, "full_name": "bibou/guy", "parent": 5, "name": "guy", "content": "Bwahahahahahaha\r\n\r\n\r\n\r\ntroll"}, "pk": 6, "model": "core.page"}] [{"pk": 1, "model": "core.page", "fields": {"full_name": "guy2", "owner_group": 1, "parent": null, "edit_group": [], "name": "guy2", "view_group": []}}, {"pk": 2, "model": "core.page", "fields": {"full_name": "guy2/bibou", "owner_group": 1, "parent": 1, "edit_group": [], "name": "bibou", "view_group": []}}, {"pk": 3, "model": "core.page", "fields": {"full_name": "guy2/bibou/troll", "owner_group": 1, "parent": 2, "edit_group": [], "name": "troll", "view_group": []}}, {"pk": 4, "model": "core.page", "fields": {"full_name": "guy", "owner_group": 1, "parent": null, "edit_group": [1], "name": "guy", "view_group": [1]}}, {"pk": 5, "model": "core.page", "fields": {"full_name": "bibou", "owner_group": 3, "parent": null, "edit_group": [1], "name": "bibou", "view_group": []}}, {"pk": 6, "model": "core.page", "fields": {"full_name": "guy2/guy", "owner_group": 1, "parent": 1, "edit_group": [], "name": "guy", "view_group": []}}]

View File

@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from core.models import User from core.models import User
from core.views.forms import RegisteringForm, LoginForm #from core.views.forms import RegisteringForm, LoginForm
class UserRegistrationTest(SimpleTestCase): class UserRegistrationTest(SimpleTestCase):
def setUp(self): def setUp(self):
@ -137,8 +137,8 @@ class UserRegistrationTest(SimpleTestCase):
'password2': 'plop', 'password2': 'plop',
}) })
response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'plop'}) response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'plop'})
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 302)
self.assertTrue('LOGIN_OK' in str(response.content)) #self.assertTrue('Hello, world' in str(response.content))
def test_login_fail(self): def test_login_fail(self):
""" """
@ -154,7 +154,14 @@ class UserRegistrationTest(SimpleTestCase):
}) })
response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'guy'}) response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'guy'})
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue('LOGIN_FAIL' in str(response.content)) self.assertTrue('Please try again' in str(response.content))
class PageHandlingTest(SimpleTestCase):
def setUp(self):
try:
Group.objects.create(name="root")
except:
pass
def test_create_page_ok(self): def test_create_page_ok(self):
""" """
@ -163,8 +170,7 @@ class UserRegistrationTest(SimpleTestCase):
c = Client() c = Client()
response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '',
'name': 'guy', 'name': 'guy',
'title': 'Guy', 'owner_group': '1',
'Content': 'Guyéuyuyé',
}) })
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue('PAGE_SAVED' in str(response.content)) self.assertTrue('PAGE_SAVED' in str(response.content))
@ -176,14 +182,11 @@ class UserRegistrationTest(SimpleTestCase):
c = Client() c = Client()
c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '',
'name': 'guy', 'name': 'guy',
'title': 'Guy', 'owner_group': 1,
'Content': 'Guyéuyuyé',
}) })
response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1',
'name': 'bibou', 'name': 'bibou',
'title': 'Bibou', 'owner_group': 1,
'Content':
'Bibibibiblblblblblbouuuuuuuuu',
}) })
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue('PAGE_SAVED' in str(response.content)) self.assertTrue('PAGE_SAVED' in str(response.content))
@ -215,7 +218,7 @@ class UserRegistrationTest(SimpleTestCase):
c = Client() c = Client()
response = c.get(reverse('core:page', kwargs={'page_name': 'swagg'})) response = c.get(reverse('core:page', kwargs={'page_name': 'swagg'}))
self.assertTrue(response.status_code == 200) self.assertTrue(response.status_code == 200)
self.assertTrue('PAGE_NOT_FOUND' in str(response.content)) self.assertTrue('<a href="/page/swagg/prop">Create it?</a>' in str(response.content))
#TODO: many tests on the pages: #TODO: many tests on the pages:
# - renaming a page # - renaming a page