Skip to content

Commit

Permalink
fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Sep 3, 2023
1 parent 3fadea9 commit 28d65ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/unit/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def test_get_simple_response_archive_to_http_scheme(

session.assert_has_calls(
[
mock.call.head(url, allow_redirects=True),
mock.call.head(url, allow_redirects=True, headers=None),
]
)
mock_raise_for_status.assert_called_once_with(session.head.return_value)
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_get_simple_response_archive_to_http_scheme_is_html(

assert resp is not None
assert session.mock_calls == [
mock.call.head(url, allow_redirects=True),
mock.call.head(url, allow_redirects=True, headers=None),
mock.call.get(
url,
headers={
Expand Down Expand Up @@ -240,14 +240,17 @@ def test_get_simple_response_dont_log_clear_text_password(
assert resp is not None
mock_raise_for_status.assert_called_once_with(resp)

assert len(caplog.records) == 2
assert len(caplog.records) == 3
record = caplog.records[0]
assert record.levelname == "DEBUG"
assert record.message.splitlines() == [
"Getting page https://user:****@example.com/simple/",
]
record = caplog.records[1]
assert record.levelname == "DEBUG"
assert record.message.splitlines() == ["headers: None"]
record = caplog.records[2]
assert record.levelname == "DEBUG"
assert record.message.splitlines() == [
"Fetched page https://user:****@example.com/simple/ as text/html",
]
Expand Down Expand Up @@ -838,7 +841,7 @@ def test_get_index_content_directory_append_index(tmpdir: Path) -> None:
mock_func.return_value = fake_response
actual = _get_index_content(Link(dir_url), session=session)
assert mock_func.mock_calls == [
mock.call(expected_url, session=session),
mock.call(expected_url, headers=None, session=session),
], f"actual calls: {mock_func.mock_calls}"

assert actual is not None
Expand Down Expand Up @@ -957,6 +960,7 @@ def test_fetch_response(self, mock_get_simple_response: mock.Mock) -> None:
# _get_simple_response().
mock_get_simple_response.assert_called_once_with(
url,
headers=None,
session=link_collector.session,
)

Expand Down

0 comments on commit 28d65ce

Please sign in to comment.