def test_register_service_public(self): collection_mock = mock.Mock(spec=["insert_one", "find_one", "count"]) collection_mock.count.return_value = 0 store = ServiceRegistry(collection=collection_mock) store.register_service(url=self.service_public['url'], name=self.service_public['name'], public=True) collection_mock.insert_one.assert_called_with(self.service_public)
def test_register_service_with_special_name(self): collection_mock = mock.Mock(spec=["insert_one", "find_one", "count"]) collection_mock.count.return_value = 0 store = ServiceRegistry(collection=collection_mock) store.register_service(url="http://wonderload", name="A special Name") collection_mock.insert_one.assert_called_with({ 'url': 'http://wonderload', 'type': 'wps', 'name': 'a_special_name', 'public': False, 'c4i': False})
def test_get_service_by_name(self): collection_mock = mock.Mock(spec=["find_one"]) collection_mock.find_one.return_value = self.service registry = ServiceRegistry(collection=collection_mock) service = registry.get_service_by_name(name=self.service['name']) collection_mock.find_one.assert_called_with({"name": self.service['name']}) assert isinstance(service, dict)