small fixes

This commit is contained in:
Qwann 2016-10-17 20:06:00 +02:00
parent 895ae3df55
commit f3180c0b3e
2 changed files with 42 additions and 1 deletions

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()