"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cyborg/tests/unit/db/test_db_device_profile.py" between
openstack-cyborg-6.0.0.tar.gz and openstack-cyborg-7.0.0.tar.gz

About: OpenStack Cyborg provides a general purpose management framework for acceleration resources.
The "Xena" series (latest release).

test_db_device_profile.py  (openstack-cyborg-6.0.0):test_db_device_profile.py  (openstack-cyborg-7.0.0)
skipping to change at line 18 skipping to change at line 18
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
"""Tests for manipulating DeviceProfile via the DB API""" """Tests for manipulating DeviceProfile via the DB API"""
import json
import sys import sys
from oslo_utils import uuidutils from oslo_utils import uuidutils
from cyborg.common import exception from cyborg.common import exception
from cyborg.tests.unit.db import base from cyborg.tests.unit.db import base
from cyborg.tests.unit.db import utils from cyborg.tests.unit.db import utils
class TestDbDeviceProfile(base.DbTestCase): class TestDbDeviceProfile(base.DbTestCase):
def test_create_dp(self):
created_dp = utils.create_test_device_profile(self.context)
expected_dp = utils.get_test_device_profile()
self.assertEqual(json.loads(created_dp.profile_json)['groups'],
json.loads(expected_dp['profile_json'])['groups'])
def test_create_dp_with_duplicate_name(self):
utils.create_test_device_profile(self.context)
duplicate_dp = utils.get_test_device_profile()
duplicate_dp['id'] = 2
duplicate_dp['uuid'] = uuidutils.generate_uuid()
self.assertRaises(exception.DuplicateDeviceProfileName,
self.dbapi.device_profile_create,
self.context, duplicate_dp)
def test_create_dp_with_duplicate_uuid(self):
utils.create_test_device_profile(self.context)
duplicate_dp = utils.get_test_device_profile()
self.assertRaises(exception.DeviceProfileAlreadyExists,
self.dbapi.device_profile_create,
self.context, duplicate_dp)
def test_get_by_uuid(self): def test_get_by_uuid(self):
created_dp = utils.create_test_device_profile(self.context) created_dp = utils.create_test_device_profile(self.context)
queried_dp = self.dbapi.device_profile_get_by_uuid( queried_dp = self.dbapi.device_profile_get_by_uuid(
self.context, created_dp['uuid']) self.context, created_dp['uuid'])
self.assertEqual(created_dp['uuid'], queried_dp['uuid']) self.assertEqual(created_dp['uuid'], queried_dp['uuid'])
self.assertIn('description', queried_dp) self.assertIn('description', queried_dp)
def test_get_by_id(self): def test_get_by_id(self):
created_dp = utils.create_test_device_profile(self.context) created_dp = utils.create_test_device_profile(self.context)
queried_dp = self.dbapi.device_profile_get_by_id( queried_dp = self.dbapi.device_profile_get_by_id(
 End of changes. 2 change blocks. 
0 lines changed or deleted 23 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)