diff --git a/event/models.py b/event/models.py index 87a38d1..d7d8ba9 100644 --- a/event/models.py +++ b/event/models.py @@ -71,7 +71,10 @@ class ActivityTag(models.Model): max_length=200, ) 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( regex=r'^#(?:[0-9a-fA-F]{3}){1,2}$', diff --git a/event/tests.py b/event/tests.py index 4db30c8..813aa3b 100644 --- a/event/tests.py +++ b/event/tests.py @@ -1,4 +1,6 @@ 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 datetime import timedelta from django.utils import timezone @@ -123,3 +125,39 @@ class ActivityInheritanceTest(TestCase): self.real_act.get_herited('tags').get().name, "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()