示例#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))
示例#2
0
文件: labels.py 项目: tirimula/ITSP
 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
示例#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