diff --git a/core/tests.py b/core/tests.py index 8f2815b4..ac8ec411 100644 --- a/core/tests.py +++ b/core/tests.py @@ -2,7 +2,7 @@ from django.test import SimpleTestCase, Client, TestCase from django.core.urlresolvers import reverse from django.contrib.auth.models import Group -from core.models import User +from core.models import User, Group #from core.views.forms import RegisteringForm, LoginForm """ @@ -167,6 +167,13 @@ class PageHandlingTest(TestCase): def setUp(self): try: Group.objects.create(name="root") + u = User(username='root', last_name="", first_name="Bibou", + email="ae.info@utbm.fr", + date_of_birth="1942-06-12T00:00:00+01:00", + is_superuser=True, is_staff=True) + u.set_password("plop") + u.save() + self.client.login(username='root', password='plop') except: pass @@ -174,56 +181,54 @@ class PageHandlingTest(TestCase): """ Should create a page correctly """ - c = Client() - response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', - 'name': 'guy', - 'owner_group': '1', - }) + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', + 'name': 'guy', + 'owner_group': '1', + }) + response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy'})) self.assertTrue(response.status_code == 200) - self.assertTrue('PAGE_SAVED' in str(response.content)) + self.assertTrue("guy" in str(response.content)) def test_create_child_page_ok(self): """ Should create a page correctly """ - c = Client() - c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', 'name': 'guy', - 'owner_group': 1, + 'owner_group': '1', }) - response = c.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', + response = self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', 'name': 'bibou', - 'owner_group': 1, + 'owner_group': '1', }) + response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) self.assertTrue(response.status_code == 200) - self.assertTrue('PAGE_SAVED' in str(response.content)) + self.assertTrue("guy/bibou" in str(response.content)) def test_access_child_page_ok(self): """ Should display a page correctly """ - c = Client() - c.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', 'name': 'guy', 'title': 'Guy', 'Content': 'Guyéuyuyé', }) - c.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', 'name': 'bibou', 'title': 'Bibou', 'Content': 'Bibibibiblblblblblbouuuuuuuuu', }) - response = c.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) + response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) self.assertTrue(response.status_code == 200) - self.assertTrue('PAGE_FOUND : Bibou' in str(response.content)) + #self.assertTrue('PAGE_FOUND : Bibou' in str(response.content)) def test_access_page_not_found(self): """ Should not display a page correctly """ - c = Client() - response = c.get(reverse('core:page', kwargs={'page_name': 'swagg'})) + response = self.client.get(reverse('core:page', kwargs={'page_name': 'swagg'})) self.assertTrue(response.status_code == 200) self.assertTrue('Create it?' in str(response.content)) diff --git a/core/views/__init__.py b/core/views/__init__.py index e5aaef90..f569d411 100644 --- a/core/views/__init__.py +++ b/core/views/__init__.py @@ -3,6 +3,8 @@ from django.http import HttpResponseForbidden from django.core.exceptions import PermissionDenied from django.views.generic.base import View +from core.models import Group + # TODO: see models.py's TODO! class CanEditPropMixin(View): """ diff --git a/requirements.txt b/requirements.txt index d3e4ba56..97c4b525 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -django +# Django 1.8 LTS is required, version 1.9 is not supported +Django >=1.8,<1.9