def post(self): """Deletes the instance group manager for the given InstanceGroupManager. Params: key: URL-safe key for a models.InstanceGroupManager. """ key = ndb.Key(urlsafe=self.request.get('key')) assert key.kind() == 'InstanceGroupManager', key instance_group_managers.delete(key)
def test_url_unspecified(self): """Ensures nothing happens when URL is unspecified.""" key = models.InstanceGroupManager( key=instance_group_managers.get_instance_group_manager_key( 'base-name', 'revision', 'zone', ), ).put() instance_group_managers.delete(key) self.failIf(key.get().url)
def test_url_not_found(self): """Ensures URL is updated when the instance group manager is not found.""" def json_request(url, *args, **kwargs): raise net.Error('', 404, '') self.mock(instance_group_managers.net, 'json_request', json_request) key = models.InstanceGroupManager( key=instance_group_managers.get_instance_group_manager_key( 'base-name', 'revision', 'zone', ), url='url', ).put() instance_group_managers.delete(key) self.failIf(key.get().url)
def test_deletes(self): """Ensures an instance group manager is deleted.""" def json_request(url, *args, **kwargs): return {'targetLink': url} self.mock(instance_group_managers.net, 'json_request', json_request) key = models.InstanceGroupManager( key=instance_group_managers.get_instance_group_manager_key( 'base-name', 'revision', 'zone', ), url='url', ).put() instance_group_managers.delete(key) self.failIf(key.get().url)
def test_target_link_mismatch(self): """Ensures nothing happens when targetLink doesn't match.""" def json_request(*args, **kwargs): return {'targetLink': 'mismatch'} self.mock(instance_group_managers.net, 'json_request', json_request) key = models.InstanceGroupManager( key=instance_group_managers.get_instance_group_manager_key( 'base-name', 'revision', 'zone', ), url='url', ).put() instance_group_managers.delete(key) self.assertEqual(key.get().url, 'url')
def test_entity_doesnt_exist(self): """Ensures nothing happens when the entity doesn't exist.""" key = ndb.Key(models.InstanceGroupManager, 'fake-key') instance_group_managers.delete(key) self.failIf(key.get())