Skip to content

Commit

Permalink
Updates made to test_check_sriov_interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mreed8855 committed Oct 3, 2024
1 parent 2dfd5a3 commit b00908f
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions providers/base/tests/test_virtualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def test_run_command_no_stderr(self, run_command_mock, logging_mock):
task.stdout = "abc"
task.stderr = None

command_result = LXDTest_vm.run_command(
MagicMock(), "command", log_stderr=True
)
command_result = LXDTest_vm.run_command(MagicMock(), "command", log_stderr=True)

self.assertTrue(logging_mock.debug.called)
self.assertTrue(command_result)
Expand All @@ -62,9 +60,7 @@ def test_run_command_error(self, run_command_mock, logging_mock):
task.stdout = "abc"
task.stderr = "some error"

command_result = LXDTest_vm.run_command(
MagicMock(), "command", log_stderr=True
)
command_result = LXDTest_vm.run_command(MagicMock(), "command", log_stderr=True)

self.assertTrue(logging_mock.error.called)
self.assertFalse(command_result)
Expand All @@ -77,9 +73,7 @@ def test_run_command_ok(self, run_command_mock, logging_mock):
task.stdout = "abc"
task.stderr = "some error"

command_result = LXDTest_vm.run_command(
MagicMock(), "command", log_stderr=True
)
command_result = LXDTest_vm.run_command(MagicMock(), "command", log_stderr=True)

self.assertTrue(logging_mock.debug.called)
self.assertTrue(command_result)
Expand All @@ -92,9 +86,7 @@ def test_run_command_ok_no_stdout(self, run_command_mock, logging_mock):
task.stdout = ""
task.stderr = "some error"

command_result = LXDTest_vm.run_command(
MagicMock(), "command", log_stderr=True
)
command_result = LXDTest_vm.run_command(MagicMock(), "command", log_stderr=True)

self.assertTrue(logging_mock.debug.called)
self.assertTrue(command_result)
Expand Down Expand Up @@ -372,9 +364,7 @@ def test_start_sriov_fail_exec(self, logging_mock, time_sleep_mock):
@patch("time.sleep")
@patch("virtualization.print")
@patch("virtualization.logging")
def test_start_sriov_success(
self, logging_mock, print_mock, time_sleep_mock
):
def test_start_sriov_success(self, logging_mock, print_mock, time_sleep_mock):
self_mock = MagicMock()
self_mock.setup.return_value = True
self_mock.image_url = "image url"
Expand Down Expand Up @@ -427,7 +417,6 @@ def exists_side_effect(path):

mock_exists.side_effect = exists_side_effect
print(f"exits side effect : {mock_exists.side_effect}")

# Mock open to return values based on the file being opened
# eth0 supports SR-IOV with 4 VFs
# Intel vendor ID for eth0
Expand All @@ -438,8 +427,8 @@ def open_side_effect(file, mode="r", *args, **kwargs):
if "eth0/device/vendor" in file:
return mock_open(read_data="0x8086").return_value
if "eth0/carrier" in file:
return mock_open(read_data="1").return_value

return mock_open(read_data="1").return_value
mock_file.side_effect = open_side_effect

# Call the function being tested
Expand Down

0 comments on commit b00908f

Please sign in to comment.