def test_zero_get_latest_snapshot(self): session = mock.MagicMock() session.describe_db_snapshots.return_value = { "DBSnapshots": [{ "DBSnapshotIdentifier": "rds:snapshot4", "Status": "pending", "SnapshotCreateTime": 200, "SnapshotType": "automatic", "DBSnapshotArn": "arn:1", "Engine": "postgres", "EngineVersion": "9.6.6", }] } with self.assertRaises(ValueError): get_latest_snapshot(session, "my-db")
def wait(state_doc, rds_session): """wait: currently waiting for the next snapshot to appear.""" logger.info( "Looking for a snapshot of %s (newer than %s)", state_doc.database, state_doc.snapshot_verified, ) snapshot = get_latest_snapshot(rds_session, state_doc.database) if snapshot.id != state_doc.snapshot_verified: # if the latest snapshot is not equal to the most recently # verified snapshot, restore and verify it. state_doc.snapshot_verifying = snapshot.id state_doc.transition_state("restore") restore(state_doc, rds_session) else: logger.info( "Did not find a snapshot of %s (newer than %s)", state_doc.database, state_doc.snapshot_verified, ) logger.info("Going to sleep.")
def test_get_latest_snapshot(self): session = mock.MagicMock() session.describe_db_snapshots.return_value = self.fake_snapshot_desc r = get_latest_snapshot(session, "my-db") self.assertEqual(r.id, "rds:snapshot3")