Skip to content

Commit

Permalink
Modify UT.
Browse files Browse the repository at this point in the history
  • Loading branch information
xincunli-sonic committed Jul 9, 2024
1 parent 67dfdc8 commit 8e27b57
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2999,7 +2999,8 @@ def test_apply_patch_dryrun_multiasic(self):
mock_config_db_connector.assert_not_called()

@patch('config.main.validate_patch', mock.Mock(return_value=True))
def test_apply_patch_parallel_multiasic(self):
@patch('config.main.concurrent.futures.wait', autospec=True)
def test_apply_patch_dryrun_parallel_multiasic(self, MockThreadPoolWait):
# Mock open to simulate file reading
with patch('builtins.open', mock_open(read_data=json.dumps(self.patch_content)), create=True) as mocked_open:
# Mock GenericUpdater to avoid actual patch application
Expand Down Expand Up @@ -3028,6 +3029,9 @@ def test_apply_patch_parallel_multiasic(self):
self.assertEqual(result.exit_code, 0, "Command should succeed")
self.assertIn("Patch applied successfully.", result.output)

# Assertions to check if ThreadPoolExecutor was used correctly
MockThreadPoolWait.assert_called_once()

# Verify mocked_open was called as expected
mocked_open.assert_called_with(self.patch_file_path, 'r')

Expand Down

0 comments on commit 8e27b57

Please sign in to comment.