Beispiel #1
0
    def test_is_valid_color(self):
        valid_colors = ['BADa55', 'FF42FF', '45DFCA']
        for color in valid_colors:
            self.assertTrue(Label.is_valid_color(color))

        invalid_colors = ['BDA55', '#FFAABB', 'FFf']
        for color in invalid_colors:
            self.assertFalse(Label.is_valid_color(color))
Beispiel #2
0
 def clean_body(self):
     color = self.body.get('color', '')
     if not Label.is_valid_color(color):
         raise ValidationError('colors must have 6 hexadecimal characters, '
                               'without # in the beggining')
     else:
         return self.body
Beispiel #3
0
 def clean_body(self):
     color = self.body.get('color', '')
     if not Label.is_valid_color(color):
         raise ValidationError('colors must have 6 hexadecimal characters, '
                               'without # in the beggining')
     else:
         return self.body