Ensure unit tests are compatible with Python 3.12
This replaces deprecated not_called and called_once_with with assert_not_called and assert_called_once_with corresponsively. Change-Id: I743d8161fb1e89ff088fc264e87887d205d2f33a
This commit is contained in:
parent
2681091ffa
commit
d1db4addf7
@ -178,7 +178,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
'"environment": {"key1": "val1", "key2": "val2"}}')
|
||||
self.assertRaises(AppError, self.post, '/v1/containers?run=wrong',
|
||||
params=params, content_type='application/json')
|
||||
self.assertTrue(mock_container_create.not_called)
|
||||
self.assertTrue(mock_container_create.assert_not_called)
|
||||
|
||||
@patch('zun.network.neutron.NeutronAPI.get_available_network')
|
||||
@patch('zun.compute.api.API.container_create')
|
||||
@ -232,7 +232,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
self.post('/v1/containers/',
|
||||
params=params,
|
||||
content_type='application/json')
|
||||
self.assertTrue(mock_container_create.not_called)
|
||||
self.assertTrue(mock_container_create.assert_not_called)
|
||||
|
||||
@patch('zun.network.neutron.NeutronAPI.get_available_network')
|
||||
@patch('zun.compute.api.API.container_create')
|
||||
@ -639,7 +639,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
self.assertEqual(
|
||||
"It is not allowed to create an interface on external network %s" %
|
||||
fake_public_network['id'], response.json['errors'][0]['detail'])
|
||||
self.assertTrue(mock_container_create.not_called)
|
||||
self.assertTrue(mock_container_create.assert_not_called)
|
||||
|
||||
@patch('zun.compute.api.API.container_create')
|
||||
@patch('zun.common.context.RequestContext.can')
|
||||
@ -787,7 +787,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
self.post('/v1/containers/',
|
||||
params=params,
|
||||
content_type='application/json')
|
||||
self.assertTrue(mock_container_create.not_called)
|
||||
self.assertTrue(mock_container_create.assert_not_called)
|
||||
mock_neutron_get_network.assert_called_once()
|
||||
|
||||
@patch('zun.compute.api.API.container_create')
|
||||
@ -799,7 +799,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
'"command": ["env"], "memory": "512"}')
|
||||
self.assertRaises(AppError, self.post, '/v1/containers/',
|
||||
params=params, content_type='application/json')
|
||||
self.assertTrue(mock_container_create.not_called)
|
||||
self.assertTrue(mock_container_create.assert_not_called)
|
||||
|
||||
@patch('zun.objects.Container.list')
|
||||
def test_get_all_containers(self, mock_container_list):
|
||||
@ -1445,7 +1445,7 @@ class TestContainerController(api_base.FunctionalTest):
|
||||
mock_delete.side_effect = exception.InvalidValue
|
||||
self.assertRaises(AppError, self.delete,
|
||||
'/v1/containers/%s?force=wrong' % test_object.uuid)
|
||||
self.assertTrue(mock_delete.not_called)
|
||||
self.assertTrue(mock_delete.assert_not_called)
|
||||
|
||||
def test_delete_container_with_uuid_not_found(self):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
|
@ -58,7 +58,7 @@ class TestImageController(api_base.FunctionalTest):
|
||||
self.post('/v1/images/',
|
||||
params=params,
|
||||
content_type='application/json')
|
||||
self.assertTrue(mock_image_pull.not_called)
|
||||
self.assertTrue(mock_image_pull.assert_not_called)
|
||||
|
||||
@mock.patch('zun.common.policy.enforce', return_value=True)
|
||||
@patch('zun.compute.api.API.image_pull')
|
||||
@ -77,7 +77,7 @@ class TestImageController(api_base.FunctionalTest):
|
||||
self.assertTrue(mock_image_pull.called)
|
||||
self.assertRaises(AppError, self.post, '/v1/images/',
|
||||
params=params, content_type='application/json')
|
||||
self.assertTrue(mock_image_pull.not_called)
|
||||
self.assertTrue(mock_image_pull.assert_not_called)
|
||||
|
||||
@mock.patch('zun.common.policy.enforce', return_value=True)
|
||||
@patch('zun.compute.api.API.image_pull')
|
||||
|
@ -287,15 +287,15 @@ class GetNetNameByVfPciAddressTestCase(base.TestCase):
|
||||
self.mock_get_ifname.return_value = self.if_name
|
||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||
self.assertEqual(ref_net_name, net_name)
|
||||
self.mock_get_mac.called_once_with(self.pci_address)
|
||||
self.mock_get_ifname.called_once_with(self.pci_address)
|
||||
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||
self.mock_get_ifname.assert_called_once_with(self.pci_address)
|
||||
|
||||
def test_wrong_mac(self):
|
||||
self.mock_get_mac.side_effect = (
|
||||
exception.PciDeviceNotFoundById(self.pci_address))
|
||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||
self.assertIsNone(net_name)
|
||||
self.mock_get_mac.called_once_with(self.pci_address)
|
||||
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||
self.mock_get_ifname.assert_not_called()
|
||||
|
||||
def test_wrong_ifname(self):
|
||||
@ -304,5 +304,5 @@ class GetNetNameByVfPciAddressTestCase(base.TestCase):
|
||||
exception.PciDeviceNotFoundById(self.pci_address))
|
||||
net_name = utils.get_net_name_by_vf_pci_address(self.pci_address)
|
||||
self.assertIsNone(net_name)
|
||||
self.mock_get_mac.called_once_with(self.pci_address)
|
||||
self.mock_get_ifname.called_once_with(self.pci_address)
|
||||
self.mock_get_mac.assert_called_once_with(self.pci_address)
|
||||
self.mock_get_ifname.assert_called_once_with(self.pci_address)
|
||||
|
Loading…
x
Reference in New Issue
Block a user