From 2b999d87bab918244010e1b72c0ad7fbbb5a23f1 Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 28 Jan 2016 10:13:45 +0100 Subject: [PATCH] Another date field update --- core/management/commands/setup.py | 6 +- core/migrations/0005_auto_20160128_0842.py | 19 ++++++ core/models.py | 2 +- core/tests.py | 77 ++++++++++++---------- 4 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 core/migrations/0005_auto_20160128_0842.py diff --git a/core/management/commands/setup.py b/core/management/commands/setup.py index 7af4e373..11ef3913 100755 --- a/core/management/commands/setup.py +++ b/core/management/commands/setup.py @@ -18,7 +18,7 @@ class Command(BaseCommand): call_command('migrate') u = User(username='root', last_name="", first_name="Bibou", email="ae.info@utbm.fr", - date_of_birth="1942-06-12T00:00:00+01:00", + date_of_birth="1942-06-12", is_superuser=True, is_staff=True) u.set_password("plop") u.save() @@ -28,13 +28,13 @@ class Command(BaseCommand): print("Dev mode, adding some test data") s = User(username='skia', last_name="Kia", first_name="S'", email="skia@git.an", - date_of_birth="1942-06-12T00:00:00+01:00", + date_of_birth="1942-06-12", is_superuser=True, is_staff=True) s.set_password("plop") s.save() u = User(username='guy', last_name="Carlier", first_name="Guy", email="guy@git.an", - date_of_birth="1942-06-12T00:00:00+01:00", + date_of_birth="1942-06-12", is_superuser=False, is_staff=False) u.set_password("plop") u.save() diff --git a/core/migrations/0005_auto_20160128_0842.py b/core/migrations/0005_auto_20160128_0842.py new file mode 100644 index 00000000..6f8c4da5 --- /dev/null +++ b/core/migrations/0005_auto_20160128_0842.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0004_auto_20160128_0835'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='date_joined', + field=models.DateField(auto_now_add=True, verbose_name='date joined'), + ), + ] diff --git a/core/models.py b/core/models.py index 23748054..9edf788f 100644 --- a/core/models.py +++ b/core/models.py @@ -60,7 +60,7 @@ class User(AbstractBaseUser, PermissionsMixin): 'Unselect this instead of deleting accounts.' ), ) - date_joined = models.DateTimeField(_('date joined'), auto_now_add=True) + date_joined = models.DateField(_('date joined'), auto_now_add=True) owner_group = models.ForeignKey(Group, related_name="owned_user", default=settings.AE_GROUPS['root']['id']) edit_group = models.ManyToManyField(Group, related_name="editable_user", blank=True) diff --git a/core/tests.py b/core/tests.py index 43bddbd0..e8fb6bc9 100644 --- a/core/tests.py +++ b/core/tests.py @@ -1,9 +1,9 @@ -from django.test import SimpleTestCase, Client, TestCase +from django.test import Client, TestCase from django.core.urlresolvers import reverse from django.contrib.auth.models import Group +from django.core.management import call_command from core.models import User, Group -#from core.views.forms import RegisteringForm, LoginForm """ to run these tests : @@ -16,8 +16,8 @@ class UserRegistrationTest(TestCase): def setUp(self): try: Group.objects.create(name="root") - except: - pass + except Exception as e: + print(e) def test_register_user_form_ok(self): """ @@ -169,22 +169,23 @@ class PageHandlingTest(TestCase): 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", + date_of_birth="1942-06-12", is_superuser=True, is_staff=True) u.set_password("plop") u.save() self.client.login(username='root', password='plop') - except: - pass + except Exception as e: + print(e) def test_create_page_ok(self): """ Should create a page correctly """ - self.client.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("guy" in str(response.content)) @@ -193,14 +194,16 @@ class PageHandlingTest(TestCase): """ Should create a page correctly """ - self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', - 'name': 'guy', - 'owner_group': '1', - }) - response = self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', - 'name': 'bibou', - 'owner_group': '1', - }) + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), { + 'parent': '', + 'name': 'guy', + 'owner_group': '1', + }) + response = self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), { + 'parent': '1', + 'name': 'bibou', + 'owner_group': '1', + }) response = self.client.get(reverse('core:page', kwargs={'page_name': 'guy/bibou'})) self.assertTrue(response.status_code == 200) self.assertTrue("guy/bibou" in str(response.content)) @@ -209,17 +212,19 @@ class PageHandlingTest(TestCase): """ Should display a page correctly """ - self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', - 'name': 'guy', - 'title': 'Guy', - 'Content': 'Guyéuyuyé', - }) - self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), {'parent': '1', - 'name': 'bibou', - 'title': 'Bibou', - 'Content': - 'Bibibibiblblblblblbouuuuuuuuu', - }) + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), { + 'parent': '', + 'name': 'guy', + 'title': 'Guy', + 'Content': 'Guyéuyuyé', + }) + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy/bibou'}), { + 'parent': '1', + 'name': 'bibou', + 'title': 'Bibou', + 'Content': + 'Bibibibiblblblblblbouuuuuuuuu', + }) 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)) @@ -237,12 +242,12 @@ class PageHandlingTest(TestCase): """ Should format the markdown and escape html correctly """ - self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), {'parent': '', - 'name': 'guy', - 'owner_group': '1', - }) - r = self.client.post(reverse('core:page_edit', kwargs={'page_name': 'guy'}), - { + self.client.post(reverse('core:page_prop', kwargs={'page_name': 'guy'}), { + 'parent': '', + 'name': 'guy', + 'owner_group': '1', + }) + r = self.client.post(reverse('core:page_edit', kwargs={'page_name': 'guy'}), { 'title': 'Bibou', 'content': '''Guy *bibou*