Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Change-Id: Ib74f8cdbccd8015ae47df6ac9fac0941f43a9f31
  • Loading branch information
ader1990 committed Nov 6, 2023
1 parent aa38b36 commit 03bffda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cloudbaseinit/tests/metadata/services/test_azureservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ def setUp(self, mock_osutils):
def tearDown(self):
self._module_patcher.stop()

@mock.patch('cloudbaseinit.utils.network.get_local_ip')
@mock.patch('time.sleep')
@mock.patch('socket.inet_ntoa')
@mock.patch('cloudbaseinit.utils.dhcp.get_dhcp_options')
def _test_get_wire_server_endpoint_address(self, mock_dhcp,
mock_inet_ntoa,
mock_time_sleep,
mock_get_local_ip,
dhcp_option=None):
mock_dhcp.return_value = dhcp_option
if not dhcp_option:
Expand Down
5 changes: 3 additions & 2 deletions cloudbaseinit/tests/metadata/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def _test_get_metadata_service(self, mock_load_class,
ret_value=mock.MagicMock(),
load_exception=False):
mock_load_class.side_effect = ret_value
fake_class = "fake_class"
if load_exception:
mock_load_class()().load.side_effect = Exception
mock_load_class(fake_class)().load.side_effect = Exception
with self.assertRaises(exception.CloudbaseInitException):
factory.get_metadata_service()
return
Expand All @@ -41,7 +42,7 @@ def _test_get_metadata_service(self, mock_load_class,
factory.get_metadata_service)
else:
response = factory.get_metadata_service()
self.assertEqual(mock_load_class()(), response)
self.assertEqual(mock_load_class(fake_class)(), response)

def test_get_metadata_service(self):
self._test_get_metadata_service()
Expand Down

0 comments on commit 03bffda

Please sign in to comment.