def test_reservation_get_all_by_values(self): """Create two reservations and verify that we can find reservation per resource_id or resource_type. """ db_api.reservation_create(_get_fake_phys_reservation_values()) db_api.reservation_create(_get_fake_virt_reservation_values()) self.assertEqual(2, len(db_api.reservation_get_all_by_values())) self.assertEqual(1, len(db_api.reservation_get_all_by_values(resource_id="5678"))) self.assertEqual(1, len(db_api.reservation_get_all_by_values(resource_type="physical:host")))
def test_create_duplicate_reservation(self): """Create duplicated reservation Create a reservation and verify that an exception is raised if a duplicated reservation is created. """ uuid = _get_fake_random_uuid() db_api.reservation_create(_get_fake_phys_reservation_values(id=uuid)) self.assertRaises(db_exceptions.ClimateDBDuplicateEntry, db_api.reservation_create, _get_fake_phys_reservation_values(id=uuid))
def test_reservation_get_all_by_values(self): """Create 2 reservations and check find abilities Create two reservations and verify that we can find reservation per resource_id or resource_type. """ db_api.reservation_create(_get_fake_phys_reservation_values()) db_api.reservation_create(_get_fake_virt_reservation_values()) self.assertEqual(2, len(db_api.reservation_get_all_by_values())) self.assertEqual(1, len(db_api.reservation_get_all_by_values( resource_id='5678'))) self.assertEqual(1, len(db_api.reservation_get_all_by_values( resource_type=host_plugin.RESOURCE_TYPE)))
def test_create_reservation(self): """Create a reservation and verify that all tables have been populated. """ result = db_api.reservation_create(_get_fake_phys_reservation_values()) self.assertEqual(result["lease_id"], _get_fake_phys_reservation_values()["lease_id"])
def test_reservation_update(self): result = db_api.reservation_create(_get_fake_phys_reservation_values()) self.assertNotEqual('fake', result.resource_type) result = db_api.reservation_update(result.id, {"resource_type": 'fake'}) self.assertEqual('fake', result.resource_type)
def test_reservation_get_all_by_values(self): """Create 2 reservations and check find abilities Create two reservations and verify that we can find reservation per resource_id or resource_type. """ db_api.reservation_create(_get_fake_phys_reservation_values()) db_api.reservation_create(_get_fake_virt_reservation_values()) self.assertEqual(2, len(db_api.reservation_get_all_by_values())) self.assertEqual( 1, len(db_api.reservation_get_all_by_values(resource_id='5678'))) self.assertEqual( 1, len( db_api.reservation_get_all_by_values( resource_type=host_plugin.RESOURCE_TYPE)))
def test_create_reservation(self): """Create and verify reservation Create a reservation and verify that all tables have been populated. """ result = db_api.reservation_create(_get_fake_phys_reservation_values()) self.assertEqual(result['lease_id'], _get_fake_phys_reservation_values()['lease_id'])
def test_delete_host_reservation(self): """Check all deletion cases for host reservation, including cascade deletion from reservations table. """ self.assertRaises(RuntimeError, db_api.host_reservation_destroy, "fake_id") result = db_api.host_reservation_create(_get_fake_host_reservation_values()) db_api.host_reservation_destroy(result["id"]) self.assertIsNone(db_api.host_reservation_get(result["id"])) reserv = db_api.reservation_create(_get_fake_phys_reservation_values()) result = db_api.host_reservation_create(_get_fake_host_reservation_values(reservation_id=reserv["id"])) db_api.reservation_destroy(reserv["id"]) self.assertIsNone(db_api.host_reservation_get(result["id"]))
def test_delete_host_reservation(self): """Check deletion for host reservation Check all deletion cases for host reservation, including cascade deletion from reservations table. """ self.assertRaises(db_exceptions.ClimateDBNotFound, db_api.host_reservation_destroy, 'fake_id') result = db_api.host_reservation_create( _get_fake_host_reservation_values()) db_api.host_reservation_destroy(result['id']) self.assertIsNone(db_api.host_reservation_get(result['id'])) reserv = db_api.reservation_create(_get_fake_phys_reservation_values()) result = db_api.host_reservation_create( _get_fake_host_reservation_values(reservation_id=reserv['id'])) db_api.reservation_destroy(reserv['id']) self.assertIsNone(db_api.host_reservation_get(result['id']))