Set lock_path correctly.
[openstack-build/neutron-build.git] / neutron / tests / unit / objects / test_objects.py
1 # Copyright 2015 IBM Corp.
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
4 #    not use this file except in compliance with the License. You may obtain
5 #    a copy of the License at
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 #    License for the specific language governing permissions and limitations
13 #    under the License.
14
15 import os
16 import pprint
17
18 from oslo_versionedobjects import base as obj_base
19 from oslo_versionedobjects import fixture
20
21 from neutron.tests import base as test_base
22
23
24 # NOTE: The hashes in this list should only be changed if they come with a
25 # corresponding version bump in the affected objects.
26 object_data = {
27     'QosBandwidthLimitRule': '1.0-4e44a8f5c2895ab1278399f87b40a13d',
28     'QosRuleType': '1.0-d0df298d49eeffab91af18d1a4cf7eaf',
29     'QosPolicy': '1.0-721fa60ea8f0e8f15d456d6e917dfe59',
30 }
31
32
33 class TestObjectVersions(test_base.BaseTestCase):
34
35     def test_versions(self):
36         checker = fixture.ObjectVersionChecker(
37             obj_base.VersionedObjectRegistry.obj_classes())
38         fingerprints = checker.get_hashes()
39
40         if os.getenv('GENERATE_HASHES'):
41             file('object_hashes.txt', 'w').write(
42                 pprint.pformat(fingerprints))
43
44         expected, actual = checker.test_hashes(object_data)
45         self.assertEqual(expected, actual,
46                          'Some objects have changed; please make sure the '
47                          'versions have been bumped, and then update their '
48                          'hashes in the object_data map in this test module.')