-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
1041f48
commit b2980f4
Showing
9 changed files
with
104 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,10 @@ | |
import pytest | ||
import requests | ||
|
||
from pushsource._impl.backend.errata_source.errata_client import ErrataHTTPClient, get_errata_client | ||
from pushsource._impl.backend.errata_source.errata_client import ( | ||
ErrataHTTPClient, | ||
get_errata_client, | ||
) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
|
@@ -17,7 +20,6 @@ def fake_temporary_file(mocker): | |
) | ||
|
||
|
||
|
||
@mock.patch.dict( | ||
"os.environ", | ||
{ | ||
|
@@ -40,8 +42,8 @@ def test_init_env_vars(): | |
def test_get_session(mock_auth, mock_session, mock_acquire, mock_name, caplog): | ||
caplog.set_level(logging.DEBUG) | ||
|
||
client = ErrataHTTPClient(1, | ||
"https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
client = ErrataHTTPClient( | ||
1, "https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
) | ||
assert not hasattr(client._tls, "session") | ||
|
||
|
@@ -59,8 +61,9 @@ def test_get_session(mock_auth, mock_session, mock_acquire, mock_name, caplog): | |
assert session == mock_session.return_value | ||
assert client._tls.session == mock_session.return_value | ||
|
||
assert caplog.messages == ["Creating HTTP client for Errata Tool: " | ||
"https://errata.example.com/"] | ||
assert caplog.messages == [ | ||
"Creating HTTP client for Errata Tool: " "https://errata.example.com/" | ||
] | ||
|
||
|
||
@mock.patch("gssapi.Name") | ||
|
@@ -72,8 +75,8 @@ def test_get_session_already_exists( | |
): | ||
caplog.set_level(logging.DEBUG) | ||
|
||
client = ErrataHTTPClient(1, | ||
"https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
client = ErrataHTTPClient( | ||
1, "https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
) | ||
assert not hasattr(client._tls, "session") | ||
session_mock = client._tls.session = mock.MagicMock() | ||
|
@@ -91,8 +94,8 @@ def test_get_session_already_exists( | |
def test_get_advisory_data(caplog): | ||
caplog.set_level(logging.DEBUG) | ||
|
||
client = ErrataHTTPClient(1, | ||
"https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
client = ErrataHTTPClient( | ||
1, "https://errata.example.com/", "/path/to/keytab", "[email protected]" | ||
) | ||
client._tls.session = requests.Session() | ||
with requests_mock.Mocker() as m: | ||
|
@@ -108,4 +111,5 @@ def test_get_advisory_data(caplog): | |
assert caplog.messages == [ | ||
"Calling Errata Tool /api/v1/erratum/{id}(RHSA-123456789)", | ||
"GET https://errata.example.com/api/v1/erratum/RHSA-123456789 200", | ||
"Errata Tool completed call /api/v1/erratum/{id}(RHSA-123456789)"] | ||
"Errata Tool completed call /api/v1/erratum/{id}(RHSA-123456789)", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,15 +6,18 @@ | |
from pushsource._impl.backend.errata_source import errata_client | ||
import requests | ||
|
||
|
||
def test_errata_client_info_logs(caplog): | ||
"""Errata client logs one INFO message per advisory queried.""" | ||
|
||
caplog.set_level(logging.INFO) | ||
|
||
client = errata_client.ErrataHTTPClient(threads=1, | ||
url="https://errata.example.com/", | ||
keytab_path="/path/to/keytab", | ||
principal="[email protected]") | ||
client = errata_client.ErrataHTTPClient( | ||
threads=1, | ||
url="https://errata.example.com/", | ||
keytab_path="/path/to/keytab", | ||
principal="[email protected]", | ||
) | ||
with patch( | ||
"pushsource._impl.backend.errata_source.errata_client.requests.Session" | ||
) as mock_proxy: | ||
|
Oops, something went wrong.