def test_publish(self): """Snapshots can be published.""" self.add_rule({ 'text': json.dumps({ 'type': 'sync', 'metadata': { 'id': 'operation-abc', 'metadata': { 'fingerprint': ('e3b0c44298fc1c149afbf4c8996fb92427' 'ae41e4649b934ca495991b7852b855') } } }), 'method': 'GET', 'url': r'^http://pylxd.test/1.0/operations/operation-abc$', }) snapshot = models.Snapshot(self.client, container=self.container, name='an-snapshot') image = snapshot.publish(wait=True) self.assertEqual( 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', image.fingerprint)
def test_publish(self): """Snapshots can be published.""" self.add_rule( { "text": json.dumps( { "type": "sync", "metadata": { "id": "operation-abc", "metadata": { "fingerprint": ( "e3b0c44298fc1c149afbf4c8996fb92427" "ae41e4649b934ca495991b7852b855" ) }, }, } ), "method": "GET", "url": r"^http://pylxd.test/1.0/operations/operation-abc$", } ) snapshot = models.Snapshot( self.client, instance=self.instance, name="an-snapshot" ) image = snapshot.publish(wait=True) self.assertEqual( "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", image.fingerprint, )
def test_delete(self): """A snapshot is deleted.""" snapshot = models.Snapshot(self.client, container=self.container, name='an-snapshot') snapshot.delete(wait=True)
def test_delete_failure(self): """If the response indicates delete failure, raise an exception.""" def not_found(request, context): context.status_code = 404 return json.dumps( {"type": "error", "error": "Not found", "error_code": 404} ) self.add_rule( { "text": not_found, "method": "DELETE", "url": ( r"^http://pylxd.test/1.0/instances/" "an-instance/snapshots/an-snapshot$" ), } ) snapshot = models.Snapshot( self.client, instance=self.instance, name="an-snapshot" ) self.assertRaises(exceptions.LXDAPIException, snapshot.delete)
def test_delete(self): """A snapshot is deleted.""" snapshot = models.Snapshot( self.client, instance=self.instance, name="an-snapshot" ) snapshot.delete(wait=True)
def test_rename(self): """A snapshot is renamed.""" snapshot = models.Snapshot(self.client, container=self.container, name='an-snapshot') snapshot.rename('an-renamed-snapshot', wait=True) self.assertEqual('an-renamed-snapshot', snapshot.name)
def test_rename(self): """A snapshot is renamed.""" snapshot = models.Snapshot( self.client, instance=self.instance, name="an-snapshot" ) snapshot.rename("an-renamed-snapshot", wait=True) self.assertEqual("an-renamed-snapshot", snapshot.name)
def test_delete_failure(self): """If the response indicates delete failure, raise an exception.""" def not_found(request, context): context.status_code = 404 return json.dumps({ 'type': 'error', 'error': 'Not found', 'error_code': 404}) self.add_rule({ 'text': not_found, 'method': 'DELETE', 'url': r'^http://pylxd.test/1.0/containers/an-container/snapshots/an-snapshot$', # NOQA }) snapshot = models.Snapshot( self.client, container=self.container, name='an-snapshot') self.assertRaises(exceptions.LXDAPIException, snapshot.delete)
def test_restore_snapshot(self): """Snapshots can be restored from the snapshot object""" snapshot = models.Snapshot(self.client, container=self.container, name='an-snapshot') snapshot.restore(wait=True)
def test_restore_snapshot(self): """Snapshots can be restored from the snapshot object""" snapshot = models.Snapshot( self.client, instance=self.instance, name="an-snapshot" ) snapshot.restore(wait=True)