def test_process_not_xml(self): requests = NotXmlRequests() ch = ConfigurationHandler(FakeHandler(), requests) ch.process_configuration('test_files/sites') self.assertEqual(2, requests.get_calls)
#!/usr/bin/env python # Copyright 2013 C. A. Fitzgerald # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import requests from shove import Shove from rssfetch import RssHandler, ItemProcessor, ConfigurationHandler finished = Shove("dbm://finished.db", "simplelru://") ch = ConfigurationHandler( RssHandler(ItemProcessor(finished,requests)), requests ) ch.process_configuration('sites.conf')
def test_process_valid_config_file_with_404_response(self): requests = FakeRequests404() ch = ConfigurationHandler(FakeHandler(), requests) ch.process_configuration('test_files/sites') self.assertEqual(2, requests.get_calls)
def test_process_valid_config_file_with_faulty_network(self): requests = FaultyFakeRequests() ch = ConfigurationHandler(FakeHandler(), requests) ch.process_configuration('test_files/sites') self.assertEqual(2, requests.get_calls)
def test_process_linkless_config_file(self): requests = FakeRequests() ch = ConfigurationHandler(FakeHandler(), requests) ch.process_configuration('test_files/linkless') self.assertEqual(0, requests.get_calls)
def test_process_invalid_config_file(self): requests = FakeRequests() ch = ConfigurationHandler(FakeHandler(), requests) with self.assertRaises(MissingSectionHeaderError): ch.process_configuration('test_files/junk') self.assertEqual(0, requests.get_calls)