def test_nothing_active(self): """Ensures nothing happens when nothing is active.""" key = models.InstanceTemplate( key=instance_templates.get_instance_template_key( 'base-name'), ).put() parse.ensure_instance_template_revision_drained(key).wait() self.failIf(key.get().active) self.failIf(key.get().drained)
def test_drains(self): """Ensures active InstanceTemplateRevision is drained.""" key = instance_templates.get_instance_template_revision_key( 'base-name', 'revision', ) models.InstanceTemplate( key=key.parent(), active=key, ).put() expected_drained = [ key, ] parse.ensure_instance_template_revision_drained(key.parent()).wait() self.failIf(key.parent().get().active) self.assertEqual(key.parent().get().drained, expected_drained)
def test_entity_not_found(self): """Ensures nothing happens when the InstanceTemplate doesn't exist.""" key = ndb.Key(models.InstanceTemplate, 'fake-key') parse.ensure_instance_template_revision_drained(key).wait() self.failIf(key.get())