Skip to content

Commit f08580e

Browse files
committed
fix: import paths for badfish src
1 parent 9899306 commit f08580e

22 files changed

+71
-71
lines changed

src/badfish/helpers/http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import aiohttp
66

7-
from src.badfish.helpers.async_lru import alru_cache
8-
from src.badfish.helpers.exceptions import BadfishException
7+
from badfish.helpers.async_lru import alru_cache
8+
from badfish.helpers.exceptions import BadfishException
99

1010

1111
class HTTPClient:

src/badfish/main.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import tempfile
1414
from urllib.parse import urlparse
1515

16-
from src.badfish.helpers import get_now
17-
from src.badfish.helpers.parser import parse_arguments
18-
from src.badfish.helpers.logger import BadfishLogger
19-
from src.badfish.helpers.http_client import HTTPClient
20-
from src.badfish.helpers.exceptions import BadfishException
16+
from badfish.helpers import get_now
17+
from badfish.helpers.parser import parse_arguments
18+
from badfish.helpers.logger import BadfishLogger
19+
from badfish.helpers.http_client import HTTPClient
20+
from badfish.helpers.exceptions import BadfishException
2121

2222
from logging import (
2323
DEBUG,

tests/config.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,15 +1058,15 @@ def render_device_dict(index, device):
10581058

10591059
KEYBOARD_INTERRUPT = "- WARNING - Badfish terminated\n"
10601060
WRONG_BADFISH_EXECUTION = "- WARNING - There was something wrong executing Badfish\n"
1061-
KEYBOARD_INTERRUPT_HOST_LIST = "[src.badfish.helpers.logger] - WARNING - Badfish terminated\n"
1061+
KEYBOARD_INTERRUPT_HOST_LIST = "[badfish.helpers.logger] - WARNING - Badfish terminated\n"
10621062
WRONG_BADFISH_EXECUTION_HOST_LIST = (
1063-
"[src.badfish.helpers.logger] - WARNING - There was something wrong executing Badfish\n"
1063+
"[badfish.helpers.logger] - WARNING - There was something wrong executing Badfish\n"
10641064
)
10651065
SUCCESSFUL_HOST_LIST = (
1066-
"[src.badfish.helpers.logger] - INFO - RESULTS:\n"
1067-
"[src.badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
1068-
"[src.badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
1069-
"[src.badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
1066+
"[badfish.helpers.logger] - INFO - RESULTS:\n"
1067+
"[badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
1068+
"[badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
1069+
"[badfish.helpers.logger] - INFO - S: SUCCESSFUL\n"
10701070
)
10711071
NO_HOST_ERROR = "- ERROR - You must specify at least either a host (-H) or a host list (--host-list).\n"
10721072
HOST_LIST_EXTRAS = (
@@ -1076,12 +1076,12 @@ def render_device_dict(index, device):
10761076
"[f01-h01-000-r630] - INFO - ************************************************\n"
10771077
"[f01-h01-000-r630] - ERROR - ComputerSystem's Members array is either empty or missing\n"
10781078
"[f01-h01-000-r630] - INFO - ************************************************\n"
1079-
"[src.badfish.helpers.logger] - INFO - RESULTS:\n"
1080-
"[src.badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
1081-
"[src.badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
1082-
"[src.badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
1079+
"[badfish.helpers.logger] - INFO - RESULTS:\n"
1080+
"[badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
1081+
"[badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
1082+
"[badfish.helpers.logger] - INFO - f01-h01-000-r630.host.io: FAILED\n"
10831083
)
1084-
HOST_FILE_ERROR = "[src.badfish.helpers.logger] - ERROR - There was something wrong reading from non/existent/file\n"
1084+
HOST_FILE_ERROR = "[badfish.helpers.logger] - ERROR - There was something wrong reading from non/existent/file\n"
10851085

10861086
# TEST SCP REQUESTS
10871087
SCP_GET_TARGETS_ACTIONS_OEM_WITH_ALLOWABLES = """

tests/test_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from aiohttp import web
66
from aiohttp.test_utils import AioHTTPTestCase
77

8-
from src.badfish.main import main
9-
from src.badfish.helpers.exceptions import BadfishException
8+
from badfish.main import main
9+
from badfish.helpers.exceptions import BadfishException
1010
from tests import config
1111

1212

tests/test_context_manager.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from unittest.mock import AsyncMock, patch, MagicMock
3-
from src.badfish.main import Badfish, badfish_factory
4-
from src.badfish.helpers.exceptions import BadfishException
3+
from badfish.main import Badfish, badfish_factory
4+
from badfish.helpers.exceptions import BadfishException
55

66

77
class MockLogger:
@@ -386,7 +386,7 @@ class TestExecuteBadfishSessionCleanup:
386386
@pytest.mark.asyncio
387387
async def test_execute_badfish_session_cleanup_success(self):
388388
"""Test successful session cleanup in execute_badfish."""
389-
from src.badfish.main import execute_badfish
389+
from badfish.main import execute_badfish
390390

391391
logger = MockLogger()
392392
args = {
@@ -451,7 +451,7 @@ async def test_execute_badfish_session_cleanup_success(self):
451451
"set_nic_attribute": None,
452452
}
453453

454-
with patch("src.badfish.main.badfish_factory") as mock_factory:
454+
with patch("badfish.main.badfish_factory") as mock_factory:
455455
# Mock badfish instance
456456
mock_badfish = MagicMock()
457457
mock_badfish.session_id = "/redfish/v1/SessionService/Sessions/123"
@@ -469,7 +469,7 @@ async def test_execute_badfish_session_cleanup_success(self):
469469
@pytest.mark.asyncio
470470
async def test_execute_badfish_session_cleanup_failure(self):
471471
"""Test session cleanup failure in execute_badfish."""
472-
from src.badfish.main import execute_badfish
472+
from badfish.main import execute_badfish
473473

474474
logger = MockLogger()
475475
args = {
@@ -534,7 +534,7 @@ async def test_execute_badfish_session_cleanup_failure(self):
534534
"set_nic_attribute": None,
535535
}
536536

537-
with patch("src.badfish.main.badfish_factory") as mock_factory:
537+
with patch("badfish.main.badfish_factory") as mock_factory:
538538
# Mock badfish instance
539539
mock_badfish = MagicMock()
540540
mock_badfish.session_id = "/redfish/v1/SessionService/Sessions/123"
@@ -556,7 +556,7 @@ async def test_execute_badfish_session_cleanup_failure(self):
556556
@pytest.mark.asyncio
557557
async def test_execute_badfish_no_session_cleanup(self):
558558
"""Test execute_badfish when no session exists to clean up."""
559-
from src.badfish.main import execute_badfish
559+
from badfish.main import execute_badfish
560560

561561
logger = MockLogger()
562562
args = {
@@ -621,7 +621,7 @@ async def test_execute_badfish_no_session_cleanup(self):
621621
"set_nic_attribute": None,
622622
}
623623

624-
with patch("src.badfish.main.badfish_factory") as mock_factory:
624+
with patch("badfish.main.badfish_factory") as mock_factory:
625625
# Mock badfish instance with no session_id
626626
mock_badfish = MagicMock()
627627
mock_badfish.session_id = None
@@ -639,7 +639,7 @@ async def test_execute_badfish_no_session_cleanup(self):
639639
@pytest.mark.asyncio
640640
async def test_execute_badfish_no_badfish_instance(self):
641641
"""Test execute_badfish when badfish instance is None."""
642-
from src.badfish.main import execute_badfish
642+
from badfish.main import execute_badfish
643643

644644
logger = MockLogger()
645645
args = {
@@ -704,7 +704,7 @@ async def test_execute_badfish_no_badfish_instance(self):
704704
"set_nic_attribute": None,
705705
}
706706

707-
with patch("src.badfish.main.badfish_factory") as mock_factory:
707+
with patch("badfish.main.badfish_factory") as mock_factory:
708708
# Mock badfish_factory to raise an exception
709709
mock_factory.side_effect = BadfishException("Connection failed")
710710

tests/test_custom_interfaces.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from src.badfish.main import Badfish
3+
from badfish.main import Badfish
44
from tests.config import INTERFACES_PATH
55
from tests.test_base import TestBase
66

tests/test_execution.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from unittest.mock import patch
33

4-
from src.badfish.helpers.exceptions import BadfishException
4+
from badfish.helpers.exceptions import BadfishException
55
from tests.config import (
66
HOST_LIST_EXTRAS,
77
KEYBOARD_INTERRUPT,
@@ -30,12 +30,12 @@ def raise_badfish_exception_stub(ignore1, ignore2, ignore3, ignore4=None):
3030
class TestSingleHostExecution(TestBase):
3131
args = ["--ls-jobs"]
3232

33-
@patch("src.badfish.main.execute_badfish", raise_keyb_interrupt_stub)
33+
@patch("badfish.main.execute_badfish", raise_keyb_interrupt_stub)
3434
def test_single_host_keyb_interrupt(self):
3535
_, err = self.badfish_call()
3636
assert err == KEYBOARD_INTERRUPT
3737

38-
@patch("src.badfish.main.execute_badfish", raise_badfish_exception_stub)
38+
@patch("badfish.main.execute_badfish", raise_badfish_exception_stub)
3939
def test_single_host_badfish_exception(self):
4040
_, err = self.badfish_call()
4141
assert err == WRONG_BADFISH_EXECUTION
@@ -52,17 +52,17 @@ class TestHostListExecution(TestBase):
5252
"--ls-jobs",
5353
]
5454

55-
@patch("src.badfish.main.execute_badfish", raise_keyb_interrupt_stub)
55+
@patch("badfish.main.execute_badfish", raise_keyb_interrupt_stub)
5656
def test_host_list_keyb_interrupt(self):
5757
_, err = self.badfish_call(mock_host=None)
5858
assert err == KEYBOARD_INTERRUPT_HOST_LIST
5959

60-
@patch("src.badfish.main.execute_badfish", raise_badfish_exception_stub)
60+
@patch("badfish.main.execute_badfish", raise_badfish_exception_stub)
6161
def test_host_list_badfish_exception(self):
6262
_, err = self.badfish_call(mock_host=None)
6363
assert err == WRONG_BADFISH_EXECUTION_HOST_LIST
6464

65-
@patch("src.badfish.main.execute_badfish")
65+
@patch("badfish.main.execute_badfish")
6666
def test_host_list_successful(self, mock_execute):
6767
mock_execute.return_value = "Successful."
6868
_, err = self.badfish_call(mock_host=None)

tests/test_firmware_inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_firmware_inventory_json_contains_error(self, mock_get, mock_post, mock_
6262
@patch("aiohttp.ClientSession.delete")
6363
@patch("aiohttp.ClientSession.post")
6464
@patch("aiohttp.ClientSession.get")
65-
@patch("src.badfish.main.Badfish.get_request")
65+
@patch("badfish.main.Badfish.get_request")
6666
def test_firmware_inventory_none_response(self, mock_get_req_call, mock_get, mock_post, mock_delete):
6767
mock_get_req_call.side_effect = [
6868
MockResponse(FIRMWARE_INVENTORY_RESP, 200), # Firmware inventory list

tests/test_hosts_file.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TestHostsFile(TestBase):
1616
def test_hosts_good(self):
1717
self.args = [self.option_arg, self.mock_hosts_good_path]
1818

19-
with patch("src.badfish.main.execute_badfish") as badfish_mock:
19+
with patch("badfish.main.execute_badfish") as badfish_mock:
2020
self.badfish_call(mock_host=None)
2121

2222
badfish_mock.assert_awaited()
@@ -32,7 +32,7 @@ def test_hosts_good(self):
3232
def test_hosts_non_existent(self):
3333
self.args = [self.option_arg, "non/existent/file"]
3434

35-
with patch("src.badfish.main.execute_badfish") as badfish_mock:
35+
with patch("badfish.main.execute_badfish") as badfish_mock:
3636
out, err = self.badfish_call(mock_host=None)
3737
badfish_mock.assert_not_awaited()
3838

@@ -44,7 +44,7 @@ def test_hosts_empty(self):
4444
"""
4545
self.args = [self.option_arg, self.mock_hosts_empty_path]
4646

47-
with patch("src.badfish.main.execute_badfish") as badfish_mock:
47+
with patch("badfish.main.execute_badfish") as badfish_mock:
4848
result = self.badfish_call(mock_host=None)
4949

5050
badfish_mock.assert_not_awaited()
@@ -53,7 +53,7 @@ def test_hosts_empty(self):
5353
def test_hosts_bad(self):
5454
self.args = [self.option_arg, self.mock_hosts_garbled_path]
5555

56-
with patch("src.badfish.main.execute_badfish") as badfish_mock:
56+
with patch("badfish.main.execute_badfish") as badfish_mock:
5757
self.badfish_call(mock_host=None)
5858

5959
badfish_mock.assert_awaited()

tests/test_http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import aiohttp
66
import pytest
77

8-
from src.badfish.helpers.http_client import HTTPClient
9-
from src.badfish.helpers.exceptions import BadfishException
8+
from badfish.helpers.http_client import HTTPClient
9+
from badfish.helpers.exceptions import BadfishException
1010

1111

1212
class DummyLogger:

0 commit comments

Comments
 (0)