Replace uuid4() with uuidsentinel

As of now, in most of the test cases, uuidsentinel is used for
generating a UUID except at some places where uuid4() is used.
In order to maintain consistency, we propose to use uuidsentinel
module for generating UUIDs throughout the test cases.

There are some cases where unique UUIDs are required. For such
cases, generate_uuid() from oslo_utils.uuidutils is used.

Change-Id: I61914796aa94b453669add2e71b3d5d704633176
This commit is contained in:
hussainchachuliya committed 2016-11-29 11:49:24 +05:30
1 parent 62a1a54940
commit 48aa351051
1 file changed
+7 -7
@@ -16,7 +16,6 @@
"""Tests for the aggregates admin api."""
import mock
import uuid
from webob import exc
from nova.api.openstack.compute import aggregates as aggregates_v21
@@ -276,11 +275,12 @@ class AggregateTestCaseV21(test.NoDBTestCase):
@mock.patch('nova.compute.api.AggregateAPI.create_aggregate')
def test_create_with_none_availability_zone(self, mock_create_agg):
mock_create_agg.return_value = objects.Aggregate(self.context,
name='test',
uuid=uuid.uuid4(),
hosts=[],
metadata={})
mock_create_agg.return_value = objects.Aggregate(
self.context,
name='test',
uuid=uuidsentinel.aggregate,
hosts=[],
metadata={})
body = {"aggregate": {"name": "test",
"availability_zone": None}}
result = self.controller.create(self.req, body=body)
@@ -406,7 +406,7 @@ class AggregateTestCaseV21(test.NoDBTestCase):
@mock.patch('nova.compute.api.AggregateAPI.update_aggregate')
def test_update_with_none_availability_zone(self, mock_update_agg):
agg_id = uuid.uuid4()
agg_id = uuidsentinel.aggregate
mock_update_agg.return_value = objects.Aggregate(self.context,
name='test',
uuid=agg_id,