Ejemplo n.º 1
0
 def test_element_trailing_space(self):
     instruction = 'html     '
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(1, len(match['elements']))
     self.assertEqual('html', match['elements'][0])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 2
0
 def test_single_id(self):
     instruction = '#id'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(1, len(match['ids']))
     self.assertEqual('id', match['ids'][0])
Ejemplo n.º 3
0
 def test_multiple_conjoined_classes(self):
     instruction = '.red.blue'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(match['elements'], None)
     self.assertEqual('red', match['classes'][0])
     self.assertEqual('blue', match['classes'][1])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 4
0
 def test_multiple_elements(self):
     instruction = 'html body'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(1, len(match['elements']))
     self.assertEqual('html', match['elements'][0])
     self.assertEqual(None, match['classes'])
     self.assertEqual(1, len(match['subMatch'].match['elements']))
     self.assertEqual(match['subMatch'].match['elements'][0], 'body')
Ejemplo n.º 5
0
 def test_element_with_class(self):
     instruction = 'p.blue'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(len(match['elements']), 1)
     self.assertEqual('p', match['elements'][0])
     self.assertEqual(len(match['classes']), 1)
     self.assertEqual('blue', match['classes'][0])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 6
0
 def test_multiple_separate_classes(self):
     instruction = '.red .blue'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(match['elements'], None)
     self.assertEqual(match['classes'][0], 'red')
     self.assertEqual(match['subMatch'].match['elements'], None)
     self.assertEqual(match['subMatch'].match['classes'][0], 'blue')
     self.assertEqual(match['subMatch'].match['subMatch'], None)
Ejemplo n.º 7
0
 def test_single_attribute(self):
     instruction = '[src]'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['ids'])
     self.assertEqual(1, len(match['attributes']))
     self.assertIn('src', match['attributes'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 8
0
 def test_element_with_id_and_class(self):
     instruction = 'p#id.class'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(1, len(match['elements']))
     self.assertEqual('p', match['elements'][0])
     self.assertEqual(1, len(match['classes']))
     self.assertEqual('class', match['classes'][0])
     self.assertEqual(1, len(match['ids']))
     self.assertEqual('id', match['ids'][0])
Ejemplo n.º 9
0
 def test_attribute_value_has_spaces(self):
     instruction = '[style=font-weight: bold;]'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['ids'])
     self.assertEqual(1, len(match['attributes']))
     self.assertIn('style', match['attributes'])
     self.assertEqual('font-weight: bold;', match['attributes']['style'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 10
0
 def test_single_attribute_with_path_value(self):
     instruction = '[src=/bbbb.jpg]'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['ids'])
     self.assertEqual(1, len(match['attributes']))
     self.assertIn('src', match['attributes'])
     self.assertEqual('/bbbb.jpg', match['attributes']['src'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 11
0
 def test_single_attribute_with_value(self):
     instruction = '[lang=en-us]'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['ids'])
     self.assertEqual(1, len(match['attributes']))
     self.assertIn('lang', match['attributes'])
     self.assertEqual('en-us', match['attributes']['lang'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 12
0
 def test_separate_class_element_id(self):
     instruction = '.class p #id'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(1, len(match['classes']))
     self.assertEqual('class', match['classes'][0])
     self.assertEqual(1, len(match['subMatch'].match['elements']))
     self.assertEqual('p', match['subMatch'].match['elements'][0])
     self.assertEqual(1,
                      len(match['subMatch'].match['subMatch'].match['ids']))
     self.assertEqual('id',
                      match['subMatch'].match['subMatch'].match['ids'][0])
Ejemplo n.º 13
0
 def test_attribute_value_has_multiple_spaces(self):
     instruction = '[style=text-indent:0px; margin-left: 23px;list-style-position:outside;]'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(None, match['elements'])
     self.assertEqual(None, match['classes'])
     self.assertEqual(None, match['ids'])
     self.assertEqual(1, len(match['attributes']))
     self.assertIn('style', match['attributes'])
     self.assertEqual(
         'text-indent:0px; margin-left: 23px;list-style-position:outside;',
         match['attributes']['style'])
     self.assertEqual(None, match['subMatch'])
Ejemplo n.º 14
0
 def test_three_elements(self):
     instruction = 'html body div'
     match = instructionSet.determinePattern(instruction)
     self.assertEqual(len(match['elements']), 1)
     self.assertEqual(match['elements'][0], 'html')
     self.assertEqual(match['classes'], None)
     self.assertEqual(len(match['subMatch'].match['elements']), 1)
     self.assertEqual(match['subMatch'].match['elements'][0], 'body')
     self.assertEqual(match['subMatch'].match['classes'], None)
     self.assertEqual(
         match['subMatch'].match['subMatch'].match['elements'][0], 'div')
     self.assertEqual(match['subMatch'].match['subMatch'].match['classes'],
                      None)