def test_registration_ok(self): '''This test case ensures all resources are registered correctly.''' registrator = ResourcesRegistrator( Mock(), file_patterns=["simple_resource.py"], folder_pattern=["tests/"]) root_folder = instantiator.get_class_abslocation(SettingsFacade) registrator.register_resources(root_folder) registry = ResourcesRegistry() resource = registry.find_by_name("Simple Resource") self.assertIsNotNone(resource) self.assertEqual(resource.name, "Simple Resource") self.assertEqual(resource.version, 1.0) self.assertEqual(resource.url, "/simple-resources") self.assertEqual(resource.subresources, {"address": ["address_id"]}) model = resource.model self.assertIsNotNone(model) from fantastico.roa.tests.simple_resource import SimpleResource self.assertEqual(model, SimpleResource)
def test_registration_ok(self): '''This test case ensures all resources are registered correctly.''' registrator = ResourcesRegistrator(Mock(), file_patterns=["simple_resource.py"], folder_pattern=["tests/"]) root_folder = instantiator.get_class_abslocation(SettingsFacade) registrator.register_resources(root_folder) registry = ResourcesRegistry() resource = registry.find_by_name("Simple Resource") self.assertIsNotNone(resource) self.assertEqual(resource.name, "Simple Resource") self.assertEqual(resource.version, 1.0) self.assertEqual(resource.url, "/simple-resources") self.assertEqual(resource.subresources, {"address": ["address_id"]}) model = resource.model self.assertIsNotNone(model) from fantastico.roa.tests.simple_resource import SimpleResource self.assertEqual(model, SimpleResource)
def test_loadroutes_ok(self): '''This test case ensures loadroutes method first scans all files for resources and then returns an empty dictionary of routes.''' expected_path = instantiator.get_class_abslocation(self.__class__) settings_facade = Mock() settings_facade.get_config = lambda: self registrator = ResourcesRegistrator(settings_facade) registrator.register_resources = Mock() self.assertEqual(registrator.load_routes(), {}) registrator.register_resources.assert_called_once_with(expected_path)