Skip to content

Commit

Permalink
Updated the unit tests for flake8 format
Browse files Browse the repository at this point in the history
  • Loading branch information
mreed8855 committed Jun 14, 2024
1 parent 9a7d3ce commit 3e59495
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions providers/base/tests/test_virtualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,10 @@ def test_start_sriov_fail_init_no_img_alias(self, logging_mock):
start_result = LXDTest_sriov.start_sriov(self_mock)

self.assertTrue(self_mock.setup.called)
self.assertFalse(start_result)
self.assertFalse(start_result)

@patch("virtualization.logging")
def test_start_sriov_fail_start(self, logging_mock):
def test_start_sriov_fail_start(self, logging_mock):
self_mock = MagicMock()
self_mock.setup.return_value = True
self_mock.image_url = "image url"
Expand All @@ -338,12 +338,12 @@ def test_start_sriov_fail_start(self, logging_mock):
self_mock.test_type = "vm"
self_mock.name = "testbed"
self_mock.run_command.side_effect = [True, False]

start_result = LXDTest_sriov.start_sriov(self_mock)

self.assertTrue(self_mock.setup.called)
self.assertFalse(start_result)
self.assertFalse(start_result)

@patch("virtualization.logging")
def test_start_sriov_fail_list(self, logging_mock):
self_mock = MagicMock()
Expand All @@ -354,12 +354,12 @@ def test_start_sriov_fail_list(self, logging_mock):
self_mock.test_type = "vm"
self_mock.name = "testbed"
self_mock.run_command.side_effect = [True, True, False]

start_result = LXDTest_sriov.start_sriov(self_mock)

self.assertTrue(self_mock.setup.called)
self.assertFalse(start_result)
self.assertFalse(start_result)

@patch("time.sleep")
@patch("virtualization.logging")
def test_start_sriov_fail_exec(self, logging_mock, time_sleep_mock):
Expand All @@ -369,16 +369,16 @@ def test_start_sriov_fail_exec(self, logging_mock, time_sleep_mock):
self_mock.template_url = "template url"
self_mock.network_name = "sriov_network"
self_mock.test_type = "vm"
self_mock.name = "testbed"
self_mock.name = "testbed"
self_mock.run_command.side_effect = itertools.chain(
[True, True, True], itertools.repeat(False)
)

start_result = LXDTest_sriov.start_sriov(self_mock)

self.assertTrue(self_mock.setup.called)
self.assertFalse(start_result)
self.assertFalse(start_result)

@patch("time.sleep")
@patch("virtualization.print")
@patch("virtualization.logging")
Expand All @@ -389,26 +389,25 @@ def test_start_sriov_success(self, logging_mock, print_mock, time_sleep_mock):
self_mock.template_url = "template url"
self_mock.network_name = "sriov_network"
self_mock.test_type = "vm"
self_mock.name = "testbed"
#self_mock.run_command.side_effect = [True, True, True, True]
self_mock.name = "testbed"
self_mock.run_command.side_effect = itertools.chain(
[True, True, True], itertools.repeat(False)
)

start_result = LXDTest_sriov.start_sriov(self_mock)

self.assertTrue(self_mock.setup.called)
self.assertFalse(start_result)
self.assertFalse(start_result)
self.assertTrue(print_mock.called)

def test_setup_failure(self):
self_mock = MagicMock()
self_mock.run_command.return_value = False
self_mock.image_url = None
self_mock.template_url = None
self_mock.network_name = None
self_mock.test_type = None
self_mock.test_type = None

setup_return = LXDTest_sriov.setup(self_mock)

self.assertFalse(setup_return)
self.assertFalse(setup_return)

0 comments on commit 3e59495

Please sign in to comment.