Example #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)
Example #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)
Example #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'))
Example #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)
Example #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)
Example #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)
Example #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)
Example #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')
Example #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')
Example #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')
Example #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)
Example #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')
Example #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')
Example #14
0
 def test_get_none_coordinate(self):
     validator = get_validator('tiny', debug=True)
     self.assertRaises(TypeError, validator.get_coordinate, None)
Example #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')
Example #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
Example #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')
Example #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
Example #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)
Example #20
0
 def _init_validator(self):
     self.validator = get_validator(self.profile,  self.debug)
Example #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)
Example #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
Example #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'))
Example #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
Example #25
0
 def test_valid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_elementname('text'))
Example #26
0
 def test_get_none_coordinate(self):
     validator = get_validator('tiny', debug=True)
     self.assertRaises(TypeError, validator.get_coordinate, None)
Example #27
0
 def test_valid_children(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_children('text', 'tspan'))
Example #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)
Example #29
0
 def test_check_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertRaises(ValueError, validator.check_valid_children, 'text', 'line')
Example #30
0
 def test_valid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_elementname('text'))
Example #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')
Example #32
0
 def test_invalid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_elementname('textArea'))
Example #33
0
 def test_invalid_elementname(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_elementname('textArea'))
Example #34
0
 def test_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_children('text', 'line'))
Example #35
0
 def test_valid_children(self):
     validator = get_validator('full', debug=True)
     self.assertTrue(validator.is_valid_children('text', 'tspan'))
Example #36
0
 def test_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertFalse(validator.is_valid_children('text', 'line'))
Example #37
0
 def test_check_invalid_children(self):
     validator = get_validator('full', debug=True)
     self.assertRaises(ValueError, validator.check_valid_children, 'text',
                       'line')
Example #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')
Example #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'))