def test_data_not_found_raises_exception(self): class FakeLoader(object): def load_file(self, name): # Returning None indicates that the # loader couldn't find anything. return None loader = Loader(file_loader=FakeLoader()) with self.assertRaises(DataNotFoundError): loader.load_data('baz')
def test_load_data_uses_loader(self): search_paths = ['foo', 'bar', 'baz'] class FakeLoader(object): def load_file(self, name): expected_ending = os.path.join('bar', 'baz') if name.endswith(expected_ending): return ['loaded data'] loader = Loader(extra_search_paths=search_paths, file_loader=FakeLoader()) loaded = loader.load_data('baz') self.assertEqual(loaded, ['loaded data'])