

def test_get_instance(self):
    launched_at = (datetime.datetime.utcnow() - datetime.timedelta(minutes=5))
    launched_at = str(launched_at)
    terminated_at = str(datetime.datetime.utcnow())
    results = [self._fake_instance(launched_at=launched_at, terminated_at=terminated_at, deleted=True)]
    self.mock_for_query('nova', (nova.GET_INSTANCE_QUERY % INSTANCE_ID_1), results)
    self.mox.ReplayAll()
    instance = self.client.get_instance('RegionOne', INSTANCE_ID_1)
    self.assertIsNotNone(instance)
    self.assertEqual(instance['id'], INSTANCE_ID_1)
    self.assertEqual(instance['instance_type_id'], INSTANCE_TYPE_ID_1)
    self.assertEqual(instance['instance_flavor_id'], INSTANCE_FLAVOR_ID_1)
    launched_at_dec = stackutils.str_time_to_unix(launched_at)
    self.assertEqual(instance['launched_at'], launched_at_dec)
    terminated_at_dec = stackutils.str_time_to_unix(terminated_at)
    self.assertEqual(instance['deleted_at'], terminated_at_dec)
    self.assertTrue(instance['deleted'])
    self.mox.VerifyAll()

dataset/ETHPy150Open openstack/stacktach/tests/unit/test_reconciler.py NovaJSONBridgeClientTestCase.test_get_instance/original