2016-10-02 14:19:38 +02:00
|
|
|
from django.contrib.auth.models import User
|
2016-09-30 20:10:35 +02:00
|
|
|
from django.test import TestCase
|
2016-10-03 00:31:21 +02:00
|
|
|
from datetime import timedelta
|
2016-10-02 14:19:38 +02:00
|
|
|
from django.utils import timezone
|
2016-10-03 00:31:21 +02:00
|
|
|
from .models import Event, ActivityTemplate, Activity, Place
|
2016-09-30 20:10:35 +02:00
|
|
|
|
2016-10-02 14:19:38 +02:00
|
|
|
|
|
|
|
class ActivityInheritanceTest(TestCase):
|
|
|
|
@classmethod
|
|
|
|
def setUpTestData(cls):
|
|
|
|
cls.erkan = User.objects.create(
|
|
|
|
username='enarmanli',
|
|
|
|
email='erkan.narmanli@ens.fr',
|
|
|
|
first_name='Erkan',
|
|
|
|
last_name='Narmanli',
|
|
|
|
)
|
|
|
|
cls.event = Event.objects.create(
|
|
|
|
title='La Nuit 2042',
|
|
|
|
slug='nuit42',
|
|
|
|
created_by=cls.erkan,
|
2016-10-03 00:31:21 +02:00
|
|
|
creation_date=timezone.now(),
|
|
|
|
description="La nuit c'est lol",
|
2016-10-02 14:19:38 +02:00
|
|
|
beginning_date=timezone.now()
|
2016-10-03 00:31:21 +02:00
|
|
|
+ timedelta(days=30),
|
2016-10-02 14:19:38 +02:00
|
|
|
ending_date=timezone.now()
|
2016-10-03 00:31:21 +02:00
|
|
|
+ timedelta(days=31),
|
2016-10-02 14:19:38 +02:00
|
|
|
)
|
2016-10-03 00:31:21 +02:00
|
|
|
cls.loge = Place.objects.create(name="Loge 45")
|
|
|
|
cls.permtemp = ActivityTemplate.objects.create(
|
|
|
|
title="Permanence loge",
|
|
|
|
# is_public non spécifié
|
|
|
|
has_perm=False,
|
|
|
|
description="Les perms c'est lol",
|
|
|
|
# remark non spécifié
|
|
|
|
)
|
|
|
|
cls.permtemp.place.add(cls.loge)
|
|
|
|
cls.perm = Activity.objects.create(
|
|
|
|
parent=cls.permtemp,
|
|
|
|
# title non spécifié
|
|
|
|
is_public=True,
|
|
|
|
# has_perm non spécifié
|
|
|
|
# description non spécifiée
|
|
|
|
remarks="lol",
|
|
|
|
)
|
|
|
|
|
|
|
|
def test_event_name(self):
|
|
|
|
self.assertEqual(self.event.title, 'La Nuit 2042')
|
|
|
|
self.assertEqual(self.loge.name, 'Loge 45')
|
|
|
|
self.assertEqual(self.permtemp.title, 'Permanence loge')
|
|
|
|
self.assertEqual(self.permtemp.place.name, 'Loge 45')
|