Wrap requests exceptions

This commit is contained in:
Mads Marquart
2020-01-15 12:17:16 +01:00
parent 8f25a3bae8
commit e25f53d9a9
4 changed files with 77 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
import pytest
import requests
from fbchat import (
FacebookError,
HTTPError,
@@ -13,6 +14,7 @@ from fbchat._exception import (
handle_payload_error,
handle_graphql_errors,
handle_http_error,
handle_requests_error,
)
@@ -123,3 +125,10 @@ def test_handle_http_error_404_handling():
def test_handle_http_error_no_error():
assert handle_http_error(200) is None
assert handle_http_error(302) is None
def test_handle_requests_error():
with pytest.raises(HTTPError, match="Connection error"):
handle_requests_error(requests.ConnectionError())
with pytest.raises(HTTPError, match="Requests error"):
handle_requests_error(requests.RequestException())