summaryrefslogtreecommitdiff
path: root/ironic/tests/unit/objects/test_portgroup.py
diff options
context:
space:
mode:
Diffstat (limited to 'ironic/tests/unit/objects/test_portgroup.py')
-rw-r--r--ironic/tests/unit/objects/test_portgroup.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/ironic/tests/unit/objects/test_portgroup.py b/ironic/tests/unit/objects/test_portgroup.py
index 81b68437b..7e844dac7 100644
--- a/ironic/tests/unit/objects/test_portgroup.py
+++ b/ironic/tests/unit/objects/test_portgroup.py
@@ -80,13 +80,18 @@ class TestPortgroupObject(db_base.DbTestCase, obj_utils.SchemasTestMixIn):
def test_create(self):
portgroup = objects.Portgroup(self.context, **self.fake_portgroup)
with mock.patch.object(self.dbapi, 'create_portgroup',
- autospec=True) as mock_create_portgroup:
- mock_create_portgroup.return_value = db_utils.get_test_portgroup()
-
- portgroup.create()
-
- args, _kwargs = mock_create_portgroup.call_args
- self.assertEqual(objects.Portgroup.VERSION, args[0]['version'])
+ autospec=True) as mock_create_pg:
+ with mock.patch.object(self.dbapi, 'get_portgroup_by_id',
+ autospec=True) as mock_get_pg:
+ test_pg = db_utils.get_test_portgroup()
+ mock_create_pg.return_value = test_pg
+ mock_get_pg.return_value = test_pg
+ mock_create_pg.return_value = db_utils.get_test_portgroup()
+
+ portgroup.create()
+
+ args, _kwargs = mock_create_pg.call_args
+ self.assertEqual(objects.Portgroup.VERSION, args[0]['version'])
def test_save(self):
uuid = self.fake_portgroup['uuid']