Models #8

Merged
narmanli merged 21 commits from models into master 2017-03-05 13:26:42 +01:00
2 changed files with 42 additions and 1 deletions
Showing only changes of commit f3180c0b3e - Show all commits

View file

@ -71,7 +71,10 @@ class ActivityTag(models.Model):
max_length=200, max_length=200,
) )
is_public = models.BooleanField( is_public = models.BooleanField(
help_text=_("TODO"), help_text=_("Sert à faire une distinction dans"
" l'affichage selon que cela soit"
" destiné au public ou à l'équipe"
" organisatrice"),
) )
color_regex = RegexValidator( color_regex = RegexValidator(
regex=r'^#(?:[0-9a-fA-F]{3}){1,2}$', regex=r'^#(?:[0-9a-fA-F]{3}){1,2}$',

View file

@ -1,4 +1,6 @@
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db.utils import DataError
from django.test import TestCase from django.test import TestCase
from datetime import timedelta from datetime import timedelta
from django.utils import timezone from django.utils import timezone
@ -123,3 +125,39 @@ class ActivityInheritanceTest(TestCase):
self.real_act.get_herited('tags').get().name, self.real_act.get_herited('tags').get().name,
"bar" "bar"
) )
class ActivityTagColorTest(TestCase):
def test_positive_color_long(self):
self.tag = ActivityTag.objects.create(
name="bar",
is_public=True,
color="#0F0F0F",
)
self.tag.full_clean()
def test_positive_color_small(self):
self.tag = ActivityTag.objects.create(
name="bar",
is_public=True,
color="#0F0",
)
self.tag.full_clean()
def test_negative_color_1(self):
self.tag = ActivityTag.objects.create(
name="bar",
is_public=True,
color="#ABCDEG",
)
with self.assertRaises(ValidationError):
self.tag.full_clean()
def test_negative_color_2(self):
self.tag = ActivityTag.objects.create(
name="bar",
is_public=True,
color="#ACDE-1",
)
with self.assertRaises(ValidationError):
self.tag.full_clean()