Пример #1
0
 def test_single_iteration_if_table_empty(self):
     parser = PageParser(table_parser=None, description_parser=MagicMock())
     parser._name = 'name'
     parser._position = 'position'
     parser._description = 'description'
     parser._stages = iter([])
     generator = parser._generator()
     actual = list(generator)
     self.assertEqual([Stage(name='name', coordinates='position', description='description', tasks=[])], actual)
Пример #2
0
 def test_generator_iterates_over_stages_once(self):
     parser = PageParser(table_parser=None, description_parser=MagicMock())
     parser._name = 'cache name'
     parser._position = 'anchor position'
     parser._description = 'cache description'
     parser._stages = iter(
         [{'name': 'stage name',
           'coordinates': 'stage position',
           'description': 'stage description',
           'tasks': {}}])
     generator = parser._generator()
     actual = list(generator)
     self.assertEqual([Stage(name='cache name',
                             coordinates='anchor position',
                             description='cache description',
                             tasks=[]), Stage(name='stage name',
                                              coordinates='stage position',
                                              description='stage description',
                                              tasks=[])], actual)
Пример #3
0
 def test_parse_calls_parse_on_table_parser(self, html_mock):
     table_parser_mock = MagicMock()
     parser = PageParser(table_parser=table_parser_mock, description_parser=None)
     parser.parse(page='irrelevant')
     self.assertTrue(table_parser_mock.parse.called)
Пример #4
0
 def test_parse_calls_html_parse(self, html_mock):
     parser = PageParser(table_parser=MagicMock(), description_parser=None)
     parser.parse(page='irrelevant')
     self.assertTrue(html_mock.parse.called)
     html_mock.parse.assert_called_with(filename_or_url='irrelevant')