Skip to content

Commit

Permalink
Remove redundant auth fixtures from conftest, replace with values in …
Browse files Browse the repository at this point in the history
…the mock_configuration fixture
  • Loading branch information
evanjt committed Aug 31, 2023
1 parent 21375e7 commit 8827b5e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
20 changes: 0 additions & 20 deletions gpm_api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,6 @@ def products() -> List[str]:
return available_products()


@pytest.fixture
def username() -> str:
"""Return a username
GPM uses an email address as username
"""

return "[email protected]"


@pytest.fixture
def password() -> str:
"""Return a password
GPM password is the username
"""

return "[email protected]"


@pytest.fixture
def server_paths() -> Dict[str, Dict[str, Any]]:
"""Return a list of probable GPM server paths"""
Expand Down
37 changes: 19 additions & 18 deletions gpm_api/tests/io/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from gpm_api.io import download as dl
from gpm_api.io.products import available_products
from gpm_api.utils.warnings import GPMDownloadWarning
from gpm_api import configs


def test_construct_curl_cmd(
username: str,
password: str,
server_paths: Dict[str, Dict[str, Any]],
tmpdir: str,
) -> None:
Expand All @@ -38,12 +37,14 @@ def test_construct_curl_cmd(
"--retry 5 --retry-delay 10 -n {server_path} -o {local_path}"
)

gpm_username, gpm_password, gpm_base_dir = configs.read_gpm_api_configs().values()

for server_path in server_paths:
path = dl.curl_cmd(
server_path=server_path,
disk_path=disk_path,
username=username,
password=password,
username=gpm_username,
password=gpm_password,
)

# Test against ftps -> ftp casting
Expand All @@ -52,8 +53,8 @@ def test_construct_curl_cmd(
server_path = server_path.replace("ftps://", "ftp://", 1)

assert path == curl_truth.format(
username=username,
password=password,
username=gpm_username,
password=gpm_password,
server_path=server_path,
local_path=disk_path,
)
Expand All @@ -65,8 +66,8 @@ def test_construct_curl_cmd(


def test_construct_wget_cmd(
username: str,
password: str,
# username: str,
# password: str,
server_paths: Dict[str, Dict[str, Any]],
tmpdir: str,
) -> None:
Expand All @@ -92,17 +93,19 @@ def test_construct_wget_cmd(
"--tries=5 -O {local_path} {server_path}"
)

gpm_username, gpm_password, gpm_base_dir = configs.read_gpm_api_configs().values()

for server_path in server_paths:
path = dl.wget_cmd(
server_path=server_path,
disk_path=disk_path,
username=username,
password=password,
username=gpm_username,
password=gpm_password,
)
print(path)

assert path == wget_truth.format(
username=username,
password=password,
username=gpm_username,
password=gpm_password,
server_path=server_path,
local_path=disk_path,
)
Expand All @@ -116,8 +119,6 @@ def test_construct_wget_cmd(
def test_download_with_ftplib(
mocker: MockerFixture,
server_paths: Dict[str, Dict[str, Any]],
username: str,
password: str,
tmpdir: str,
) -> None:
ftp_mock = mocker.patch(
Expand All @@ -143,12 +144,12 @@ def test_download_with_ftplib(
os.path.basename(server_path),
)
)

gpm_username, gpm_password, gpm_base_dir = configs.read_gpm_api_configs().values()
dl.ftplib_download(
server_paths=server_paths.keys(),
disk_paths=server_paths,
username=username,
password=password,
username=gpm_username,
password=gpm_password,
)

assert ftp_mock.called

Check notice on line 155 in gpm_api/tests/io/test_download.py

View check run for this annotation

codefactor.io / CodeFactor

gpm_api/tests/io/test_download.py#L155

unresolved comment '# TODO: Assert username/password are passed to ftp_mock.login (assert_called_with not working?)' (C100)
Expand Down

0 comments on commit 8827b5e

Please sign in to comment.