]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix invalid uuid warnings in scheduler unit tests
authorTom Barron <tpb@dyncloud.net>
Mon, 29 Feb 2016 12:48:04 +0000 (07:48 -0500)
committerTom Barron <tpb@dyncloud.net>
Mon, 29 Feb 2016 16:12:24 +0000 (11:12 -0500)
Currently 'tox -epy27 -- --regex cinder.tests.unit.scheduler' emits
twenty FutureWarnings from oslo.versionedobjects about invalid uuids
as documented here[1].

This commit changes these tests to use valid uuids so that when they
are run these warnings are no longer emitted.

Change-Id: I38187b159b9e42984fcf61cb4b77a94f00a56818

cinder/tests/unit/fake_consistencygroup.py
cinder/tests/unit/scheduler/test_host_filters.py
cinder/tests/unit/scheduler/test_scheduler.py

index 280959c308bea5e0fe10ad0185f9a88b800bd91d..fa526c2aab7223fdce40a830eec477573cedc543 100644 (file)
 from oslo_versionedobjects import fields
 
 from cinder import objects
+from cinder.tests.unit import fake_constants as fake
 
 
 def fake_db_consistencygroup(**updates):
     db_values = {
-        'id': '1',
-        'user_id': '2',
-        'project_id': '3',
+        'id': fake.consistency_group_id,
+        'user_id': fake.user_id,
+        'project_id': fake.project_id,
         'host': 'FakeHost',
         'volumes': [],
     }
index 9e5dca11907474b84385fff5df208bc8729bad8c..f988c300e8981c66bdc629f5a657dd128d3e99f4 100644 (file)
@@ -25,6 +25,7 @@ from cinder import db
 from cinder import exception
 from cinder.scheduler import filters
 from cinder import test
+from cinder.tests.unit import fake_constants as fake
 from cinder.tests.unit.scheduler import fakes
 from cinder.tests.unit import utils
 
@@ -34,7 +35,7 @@ class HostFiltersTestCase(test.TestCase):
 
     def setUp(self):
         super(HostFiltersTestCase, self).setUp()
-        self.context = context.RequestContext('fake', 'fake')
+        self.context = context.RequestContext(fake.user_id, fake.project_id)
         # This has a side effect of testing 'get_filter_classes'
         # when specifying a method (in this case, our standard filters)
         filter_handler = filters.HostFilterHandler('cinder.scheduler.filters')
index b5c6f709d443ecacc43d12be23341408c629138e..fc8e074f332b977ee8414df7358ec3c1a40b452a 100644 (file)
@@ -29,6 +29,7 @@ from cinder.scheduler import filter_scheduler
 from cinder.scheduler import manager
 from cinder import test
 from cinder.tests.unit import fake_consistencygroup
+from cinder.tests.unit import fake_constants as fake
 from cinder.tests.unit import fake_volume
 from cinder.tests.unit import utils as tests_utils
 
@@ -287,7 +288,7 @@ class SchedulerManagerTestCase(test.TestCase):
 
             ex = exception.CinderException('test')
             mock_cg.side_effect = ex
-            group_id = '1'
+            group_id = fake.consistency_group_id
             self.assertRaises(exception.CinderException,
                               self.manager.create_consistencygroup,
                               self.context,
@@ -323,7 +324,7 @@ class SchedulerTestCase(test.TestCase):
     def setUp(self):
         super(SchedulerTestCase, self).setUp()
         self.driver = self.driver_cls()
-        self.context = context.RequestContext('fake_user', 'fake_project')
+        self.context = context.RequestContext(fake.user_id, fake.project_id)
         self.topic = 'fake_topic'
 
     @mock.patch('cinder.scheduler.driver.Scheduler.'
@@ -366,7 +367,7 @@ class SchedulerDriverModuleTestCase(test.TestCase):
 
     def setUp(self):
         super(SchedulerDriverModuleTestCase, self).setUp()
-        self.context = context.RequestContext('fake_user', 'fake_project')
+        self.context = context.RequestContext(fake.user_id, fake.project_id)
 
     @mock.patch('cinder.db.volume_update')
     @mock.patch('cinder.objects.volume.Volume.get_by_id')