def status(self, name): index, instance = self.find_instance(name) if index < 0: raise storage.InstanceNotFoundError() return instance.state
def info(self, name): index, instance = self.find_instance(name) if index < 0: raise storage.InstanceNotFoundError() return {"name": instance.name, "secret": "wat"}
def remove_instance(self, name): index, _ = self.find_instance(name) if index == -1: raise storage.InstanceNotFoundError() del self.instances[index]
def unbind(self, name, app_host): index, instance = self.find_instance(name) if index < 0: raise storage.InstanceNotFoundError() instance.unbind(app_host)
def test_status_instance_not_found_in_storage(self): storage = mock.Mock() storage.retrieve_instance.side_effect = api_storage.InstanceNotFoundError() manager = managers.BaseManager(storage) with self.assertRaises(api_storage.InstanceNotFoundError): manager.status("secret")
def test_new_instance(self): storage = mock.Mock() storage.retrieve_instance.side_effect = api_storage.InstanceNotFoundError() manager = managers.BaseManager(storage) instance = manager.new_instance("someapp") storage.store_instance.assert_called_with(instance)