-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli_errors.py
More file actions
35 lines (29 loc) · 1.27 KB
/
Copy pathtest_cli_errors.py
File metadata and controls
35 lines (29 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
from gh_similarity_detector.cli.error_handler import handle_cli_error
from gh_similarity_detector.infrastructure.github_client.client import (
RateLimitError,
NotFoundError,
GitHubPermissionError,
GitHubAPIError,
)
class TestCLIErrorHandling:
def test_rate_limit_error_exit_code(self):
with pytest.raises(SystemExit) as exc_info:
handle_cli_error(RateLimitError(403, "rate limited", retry_after=3600))
assert exc_info.value.code == 2
def test_not_found_error_exit_code(self):
with pytest.raises(SystemExit) as exc_info:
handle_cli_error(NotFoundError(404, "not found"))
assert exc_info.value.code == 3
def test_permission_error_exit_code(self):
with pytest.raises(SystemExit) as exc_info:
handle_cli_error(GitHubPermissionError(403, "forbidden"))
assert exc_info.value.code == 4
def test_api_error_exit_code(self):
with pytest.raises(SystemExit) as exc_info:
handle_cli_error(GitHubAPIError(500, "server error"))
assert exc_info.value.code == 5
def test_generic_error_exit_code(self):
with pytest.raises(SystemExit) as exc_info:
handle_cli_error(ValueError("something wrong"))
assert exc_info.value.code == 1