def test_no_active_metadata_update(self): """Ensures nothing happens when active metadata update is unspecified.""" key = models.Instance(key=instances.get_instance_key( 'base-name', 'revision', 'zone', 'instance-name', ), ).put() metadata.associate_metadata_operation(key, 'checksum', 'url') self.failIf(key.get().active_metadata_update)
def test_checksum_mismatch(self): """Ensures nothing happens when the metadata checksum doesn't match.""" key = models.Instance( key=instances.get_instance_key( 'base-name', 'revision', 'zone', 'instance-name', ), active_metadata_update=models.MetadataUpdate(metadata={ 'key': 'value', }, ), ).put() metadata.associate_metadata_operation(key, 'checksum', 'url') self.failIf(key.get().active_metadata_update.url)
def test_associates_url(self): """Ensures a URL is associated.""" key = models.Instance( key=instances.get_instance_key( 'base-name', 'revision', 'zone', 'instance-name', ), active_metadata_update=models.MetadataUpdate(metadata={ 'key': 'value', }, ), ).put() checksum = key.get().active_metadata_update.checksum expected_url = 'url' metadata.associate_metadata_operation(key, checksum, 'url') self.assertEqual(key.get().active_metadata_update.url, expected_url)
def test_not_found(self): """Ensures nothing happens when the entity doesn't exist.""" key = ndb.Key(models.Instance, 'fake-key') metadata.associate_metadata_operation(key, 'checksum', 'url') self.failIf(key.get())