コード例 #1
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
 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")))
コード例 #2
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
    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))
コード例 #3
0
    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))
コード例 #4
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
    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)))
コード例 #5
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
    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"])
コード例 #6
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
    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)
コード例 #7
0
    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)
コード例 #8
0
    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)))
コード例 #9
0
    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'])
コード例 #10
0
ファイル: test_sqlalchemy_api.py プロジェクト: sbauza/climate
    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"]))
コード例 #11
0
ファイル: test_sqlalchemy_api.py プロジェクト: hshah19/blazar
    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']))
コード例 #12
0
    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']))