From 50f53e7a6ee7636b4dd62fe5972988fb829e0a38 Mon Sep 17 00:00:00 2001 From: Skia Date: Wed, 2 Dec 2015 17:14:47 +0100 Subject: [PATCH] Fix users tests and pages fixtures --- core/fixtures/pages.json | 2 +- core/tests.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/fixtures/pages.json b/core/fixtures/pages.json index dc8073b2..83c1380a 100644 --- a/core/fixtures/pages.json +++ b/core/fixtures/pages.json @@ -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"}] \ No newline at end of file +[{"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": []}}] \ No newline at end of file diff --git a/core/tests.py b/core/tests.py index 989569ab..59f17978 100644 --- a/core/tests.py +++ b/core/tests.py @@ -3,7 +3,7 @@ from django.core.urlresolvers import reverse from django.contrib.auth.models import Group from core.models import User -from core.views.forms import RegisteringForm, LoginForm +#from core.views.forms import RegisteringForm, LoginForm class UserRegistrationTest(SimpleTestCase): def setUp(self): @@ -137,8 +137,8 @@ class UserRegistrationTest(SimpleTestCase): 'password2': 'plop', }) response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'plop'}) - self.assertTrue(response.status_code == 200) - self.assertTrue('LOGIN_OK' in str(response.content)) + self.assertTrue(response.status_code == 302) + #self.assertTrue('Hello, world' in str(response.content)) def test_login_fail(self): """ @@ -154,7 +154,14 @@ class UserRegistrationTest(SimpleTestCase): }) response = c.post(reverse('core:login'), {'username': 'gcarlier', 'password': 'guy'}) 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): """ @@ -163,8 +170,7 @@ class UserRegistrationTest(SimpleTestCase): c = Client() response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', 'name': 'guy', - 'title': 'Guy', - 'Content': 'Guyéuyuyé', + 'owner_group': '1', }) self.assertTrue(response.status_code == 200) self.assertTrue('PAGE_SAVED' in str(response.content)) @@ -176,14 +182,11 @@ class UserRegistrationTest(SimpleTestCase): c = Client() c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', 'name': 'guy', - 'title': 'Guy', - 'Content': 'Guyéuyuyé', + 'owner_group': 1, }) response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', 'name': 'bibou', - 'title': 'Bibou', - 'Content': - 'Bibibibiblblblblblbouuuuuuuuu', + 'owner_group': 1, }) self.assertTrue(response.status_code == 200) self.assertTrue('PAGE_SAVED' in str(response.content)) @@ -215,7 +218,7 @@ class UserRegistrationTest(SimpleTestCase): c = Client() response = c.get(reverse('core:page', kwargs={'page_name': 'swagg'})) self.assertTrue(response.status_code == 200) - self.assertTrue('PAGE_NOT_FOUND' in str(response.content)) + self.assertTrue('Create it?' in str(response.content)) #TODO: many tests on the pages: # - renaming a page