From d3f30c4d8f75de8a806fd7361cf8627b2b1e4a9f Mon Sep 17 00:00:00 2001 From: Felipe Reyes Date: Wed, 22 Mar 2023 15:04:58 -0300 Subject: [PATCH] Fix unittest - Replace ".has_calls(...)" with ".assert_has_calls(...)" - Use "self.Client()" instead of "self.Client", because otherwise the wrong mock object is tested. Related-Bug: #2012108 Change-Id: I8649ba727a75c8dcb86404ed4c3def12e0fdda01 --- unit_tests/test_actions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/unit_tests/test_actions.py b/unit_tests/test_actions.py index 1e19f036..26dd7510 100644 --- a/unit_tests/test_actions.py +++ b/unit_tests/test_actions.py @@ -273,30 +273,30 @@ class SyncComputeAvailabilityZonesTestCase(CharmTestCase): self.Session.assert_called_once_with(auth='v3-password-instance') self.Client.assert_called_once_with(2, session='keystone-session') self.relation_ids.assert_called_once_with('cloud-compute') - self.related_units.has_calls([ + self.related_units.assert_has_calls([ mock.call('r:1'), mock.call('r:2') ]) - self.relation_get.has_calls([ + self.relation_get.assert_has_calls([ mock.call(rid='r:1', unit='aservice/0'), mock.call(rid='r:1', unit='aservice/1'), mock.call(rid='r:1', unit='aservice/2'), mock.call(rid='r:2', unit='bservice/0'), mock.call(rid='r:2', unit='bservice/1'), ]) - self.Client.aggregates.find.has_calls([ + self.Client().aggregates.find.assert_has_calls([ mock.call(name='site-a_az', availability_zone='site-a'), mock.call(name='site-b_az', availability_zone='site-b'), mock.call(name='site-c_az', availability_zone='site-c'), mock.call(name='site-d_az', availability_zone='site-d'), ]) - self.Client.hypervisors.find.has_calls([ + self.Client().hypervisors.find.assert_has_calls([ mock.call(host_ip='10.0.0.1'), mock.call(host_ip='10.0.0.2'), mock.call(host_ip='10.0.1.1'), mock.call(host_ip='10.0.1.2'), ]) - self.Client.aggregates.add_host.has_calls([ + self.Client().aggregates.add_host.assert_has_calls([ mock.call(aggregate_mocks[0], 'node-1'), mock.call(aggregate_mocks[1], 'node-2'), mock.call(aggregate_mocks[2], 'node-3'),