class InterfaceTests(TestCase): ''' Tests the public interface of the parser and asserts that the underlying implementation is called correctly. It is not testing any actual content processing. ''' def setUp(self): self.static_content_mock = StaticContentMock() self.static_content_mock.selector_set.all = Mock(return_value=[]) self.parser = StaticContentParser(self.static_content_mock) def teardown(self): pass @patch('dasdocc.aggregator.lib.static_content_helpers.html.parse') def test_parser_should_collect_data_during_get_nodes(self, parse): parse.return_value = static_content_parsed() self.parser.get_nodes() parse.assert_called_once_with('http://mocked.source/') @patch('dasdocc.aggregator.lib.static_content_helpers.html.parse') def test_parser_should_collect_data_during_process_nodes(self, parse): parse.return_value = static_content_parsed() self.parser.process_nodes() parse.assert_called_once_with('http://mocked.source/') @patch('dasdocc.aggregator.lib.static_content_helpers.html.parse') def test_parser_should_parse_data_only_once(self, parse): parse.return_value = static_content_parsed() self.parser.process_nodes() self.parser.get_nodes() self.parser.process_nodes() self.parser.get_nodes() parse.assert_called_once_with('http://mocked.source/')
def run(self): self.instance.staticcontenterror_set.all().delete() parser = StaticContentParser(self.instance) parser.process_nodes() return True