Skip to content

Commit

Permalink
🎨 Improve some small details
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikspiess committed Feb 26, 2024
1 parent b162c41 commit 08d2aa5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions fotoobo/fortinet/fortinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def api( # pylint: disable=too-many-arguments
timeout = timeout or self.timeout
start = time()

if method.upper() not in self.ALLOWED_HTTP_METHODS:
error = f"HTTP method '{method.lower()}' is not implemented"
if method.upper() not in Fortinet.ALLOWED_HTTP_METHODS:
error = f"HTTP method '{method.upper()}' is not implemented"
log.error(error)
raise NotImplementedError(error)

Expand All @@ -112,6 +112,7 @@ def api( # pylint: disable=too-many-arguments
except requests.exceptions.SSLError as err:
log.debug(err)
error = "Unknown SSL error"

try:
if (
err.args[0].reason.args[0].verify_message
Expand All @@ -131,6 +132,7 @@ def api( # pylint: disable=too-many-arguments
except requests.exceptions.ConnectionError as err:
log.debug(err)
error = "Unknown connection error"

try:
if "Name or service not known" in err.args[0].reason.args[0]:
error = "Name or service not known"
Expand Down
2 changes: 1 addition & 1 deletion tests/fortinet/test_fortinet.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_api_get_read_timeout(method: str, monkeypatch: MonkeyPatch) -> None:
@staticmethod
def test_api_unknown_method() -> None:
"""Test api with unknown method"""
with pytest.raises(NotImplementedError, match=r"HTTP method 'dummy' is not implemented"):
with pytest.raises(NotImplementedError, match=r"HTTP method 'DUMMY' is not implemented"):
FortinetTestClass("dummy").api("dummy", "url")

@staticmethod
Expand Down

0 comments on commit 08d2aa5

Please sign in to comment.