Ejemplo n.º 1
0
 def test_not_valid_tiny_values(self):
     validator = get_validator('tiny', debug=True)
     for value in (100000, '100000', -100000, '-100000'):
         self.assertRaises(ValueError, validator.get_coordinate, value)
     # but valid for full profile - do not raise an error
     validator = get_validator('full', debug=True)
     for value in (100000, '100000', -100000, '-100000'):
         validator.get_coordinate(value)
Ejemplo n.º 2
0
 def test_not_valid_tiny_values(self):
     validator = get_validator('tiny', debug=True)
     for value in (100000, '100000', -100000, '-100000'):
         self.assertRaises(ValueError, validator.get_coordinate, value)
     # but valid for full profile - do not raise an error
     validator = get_validator('full', debug=True)
     for value in (100000, '100000', -100000, '-100000'):
         validator.get_coordinate(value)
Ejemplo n.º 3
0
 def test_color(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.check_svg_type("red", 'color'))
     self.assertTrue(validator.check_svg_type("#000000", 'color'))
     self.assertTrue(validator.check_svg_type("rgb(10%, 20%, 30%)",
                                              'color'))
     self.assertTrue(
         validator.check_svg_type("rgb(10.1%, 20.2%, 30.3%)", 'color'))
Ejemplo n.º 4
0
 def test_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value, number, unit in [(' 100px ', 100, 'px'),
                                 (' -100ex ', -100, 'ex'),
                                 (' 100em ', 100, 'em'),
                                 (' -100pt ', -100, 'pt'),
                                 (' 100pc ', 100, 'pc'),
                                 (' 100mm', 100, 'mm'),
                                 (' 100cm', 100, 'cm'),
                                 (' 100in', 100, 'in'),
                                 (' 5%', 5, '%')]:
         value2 = validator.check_svg_type(value, 'coordinate') # checks also value pass through
         self.assertEqual(value, value2)
Ejemplo n.º 5
0
 def test_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value, number, unit in [(' 100px ', 100, 'px'),
                                 (' -100ex ', -100, 'ex'),
                                 (' 100em ', 100, 'em'),
                                 (' -100pt ', -100, 'pt'),
                                 (' 100pc ', 100, 'pc'),
                                 (' 100mm', 100, 'mm'),
                                 (' 100cm', 100, 'cm'),
                                 (' 100in', 100, 'in'), (' 5%', 5, '%')]:
         number2, unit2 = validator.get_coordinate(value)
         self.assertEqual(number2, number)
         self.assertEqual(unit2, unit)
Ejemplo n.º 6
0
 def test_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value, number, unit in [(' 100px ', 100, 'px'),
                                 (' -100ex ', -100, 'ex'),
                                 (' 100em ', 100, 'em'),
                                 (' -100pt ', -100, 'pt'),
                                 (' 100pc ', 100, 'pc'),
                                 (' 100mm', 100, 'mm'),
                                 (' 100cm', 100, 'cm'),
                                 (' 100in', 100, 'in'), (' 5%', 5, '%')]:
         value2 = validator.check_svg_type(
             value, 'coordinate')  # checks also value pass through
         self.assertEqual(value, value2)
Ejemplo n.º 7
0
 def test_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value, number, unit in [(' 100px ', 100, 'px'),
                                 (' -100ex ', -100, 'ex'),
                                 (' 100em ', 100, 'em'),
                                 (' -100pt ', -100, 'pt'),
                                 (' 100pc ', 100, 'pc'),
                                 (' 100mm', 100, 'mm'),
                                 (' 100cm', 100, 'cm'),
                                 (' 100in', 100, 'in'),
                                 (' 5%', 5, '%')]:
         number2, unit2 = validator.get_coordinate(value)
         self.assertEqual(number2, number)
         self.assertEqual(unit2, unit)
Ejemplo n.º 8
0
 def test_text_decoration_styles(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(
         validator.check_svg_type('overline',
                                  'list-of-text-decoration-style'))
     self.assertTrue(
         validator.check_svg_type('underline',
                                  'list-of-text-decoration-style'))
     self.assertTrue(
         validator.check_svg_type('line-through',
                                  'list-of-text-decoration-style'))
     self.assertTrue(
         validator.check_svg_type('blink', 'list-of-text-decoration-style'))
     self.assertTrue(
         validator.check_svg_type('underline overline blink',
                                  'list-of-text-decoration-style'))
     with self.assertRaises(TypeError):
         validator.check_svg_type('underline overline inherit',
                                  'list-of-text-decoration-style')
Ejemplo n.º 9
0
 def test_not_valid_numbers(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 1s00in ', ' 1s00mm ', ' 1s00% '):
         self.assertRaises(TypeError, validator.check_svg_type, value, 'coordinate')
Ejemplo n.º 10
0
 def test_not_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 100km ', ' 100mi ', ' 100$ '):
         self.assertRaises(TypeError, validator.check_svg_type, value,
                           'coordinate')
Ejemplo n.º 11
0
 def test_not_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 100km ', ' 100mi ', ' 100$ '):
         self.assertRaises(ValueError, validator.get_coordinate, value)
Ejemplo n.º 12
0
 def test_invalid_angle(self):
     validator = get_validator('tiny', debug=True)
     for value in ('10cm', '-10px', '10in', '1gon', '3°'):
         self.assertRaises(TypeError, validator.check_svg_type, value, 'angle')
Ejemplo n.º 13
0
 def test_invalid_tiny(self):
     validator = get_validator('tiny', debug=True)
     for value in (100000, -100000., -32768, 32768):
         self.assertRaises(TypeError, validator.check_svg_type, value, 'number')
Ejemplo n.º 14
0
 def test_get_none_coordinate(self):
     validator = get_validator('tiny', debug=True)
     self.assertRaises(TypeError, validator.get_coordinate, None)
Ejemplo n.º 15
0
 def test_invalid_angle(self):
     validator = get_validator('tiny', debug=True)
     for value in ('10cm', '-10px', '10in', '1gon', '3°'):
         self.assertRaises(TypeError, validator.check_svg_type, value,
                           'angle')
Ejemplo n.º 16
0
 def test_valid_angle(self):
     validator = get_validator('tiny', debug=True)
     for value in ('100deg', '0.5grad', '-1.5rad'):
         validator.check_svg_type(value,
                                  'angle')  # no exception should raised
Ejemplo n.º 17
0
 def test_invalid_tiny(self):
     validator = get_validator('tiny', debug=True)
     for value in (100000, -100000., -32768, 32768):
         self.assertRaises(TypeError, validator.check_svg_type, value,
                           'number')
Ejemplo n.º 18
0
 def test_valid_tiny(self):
     validator = get_validator('tiny', debug=True)
     for value in (10000, 0, -10000., -32767.9999, +32767.9999):
         validator.check_svg_type(value,
                                  'number')  # no exception should raised
Ejemplo n.º 19
0
 def test_not_valid_numbers(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 1s00in ', ' 1s00mm ', ' 1s00% '):
         self.assertRaises(ValueError, validator.get_coordinate, value)
         self.assertRaises(ValueError, validator.get_length, value)
Ejemplo n.º 20
0
 def _init_validator(self):
     self.validator = get_validator(self.profile,  self.debug)
Ejemplo n.º 21
0
 def test_not_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 100km ', ' 100mi ', ' 100$ '):
         self.assertRaises(ValueError, validator.get_coordinate, value)
Ejemplo n.º 22
0
 def test_valid_tiny(self):
     validator = get_validator('tiny', debug=True)
     for value in (10000, 0, -10000., -32767.9999, +32767.9999):
         validator.check_svg_type(value, 'number') # no exception should raised
Ejemplo n.º 23
0
 def test_color(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.check_svg_type("red", 'color'))
     self.assertTrue(validator.check_svg_type("#000000", 'color'))
     self.assertTrue(validator.check_svg_type("rgb(10%, 20%, 30%)", 'color'))
     self.assertTrue(validator.check_svg_type("rgb(10.1%, 20.2%, 30.3%)", 'color'))
Ejemplo n.º 24
0
 def test_valid_angle(self):
     validator = get_validator('tiny', debug=True)
     for value in ('100deg', '0.5grad', '-1.5rad'):
         validator.check_svg_type(value, 'angle') # no exception should raised
Ejemplo n.º 25
0
 def test_valid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_elementname('text'))
Ejemplo n.º 26
0
 def test_get_none_coordinate(self):
     validator = get_validator('tiny', debug=True)
     self.assertRaises(TypeError, validator.get_coordinate, None)
Ejemplo n.º 27
0
 def test_valid_children(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_children('text', 'tspan'))
Ejemplo n.º 28
0
 def test_not_valid_numbers(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 1s00in ', ' 1s00mm ', ' 1s00% '):
         self.assertRaises(ValueError, validator.get_coordinate, value)
         self.assertRaises(ValueError, validator.get_length, value)
Ejemplo n.º 29
0
 def test_check_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertRaises(ValueError, validator.check_valid_children, 'text', 'line')
Ejemplo n.º 30
0
 def test_valid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_elementname('text'))
Ejemplo n.º 31
0
 def test_not_valid_numbers(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 1s00in ', ' 1s00mm ', ' 1s00% '):
         self.assertRaises(TypeError, validator.check_svg_type, value,
                           'coordinate')
Ejemplo n.º 32
0
 def test_invalid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_elementname('textArea'))
Ejemplo n.º 33
0
 def test_invalid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_elementname('textArea'))
Ejemplo n.º 34
0
 def test_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_children('text', 'line'))
Ejemplo n.º 35
0
 def test_valid_children(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_children('text', 'tspan'))
Ejemplo n.º 36
0
 def test_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_children('text', 'line'))
Ejemplo n.º 37
0
 def test_check_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertRaises(ValueError, validator.check_valid_children, 'text',
                       'line')
Ejemplo n.º 38
0
 def test_not_valid_units(self):
     validator = get_validator('tiny', debug=True)
     for value in (' 100km ', ' 100mi ', ' 100$ '):
         self.assertRaises(TypeError, validator.check_svg_type, value, 'coordinate')
Ejemplo n.º 39
0
 def test_class_names(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(
         validator.is_valid_svg_type('class1 class2', 'list-of-name'))