-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6499cd
commit 168f501
Showing
1 changed file
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from typing import Type | ||
from unittest.mock import Mock, patch | ||
|
||
import pytest | ||
|
||
from blueapi.client.rest import BlueapiRestClient, BlueskyRemoteControlError | ||
|
||
|
||
@pytest.fixture | ||
def rest() -> BlueapiRestClient: | ||
return BlueapiRestClient() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"code,expected_exception", | ||
[ | ||
(404, KeyError), | ||
(450, BlueskyRemoteControlError), | ||
(500, BlueskyRemoteControlError), | ||
], | ||
) | ||
@patch("blueapi.client.rest.requests.request") | ||
def test_rest_error_code( | ||
mock_request: Mock, | ||
rest: BlueapiRestClient, | ||
code: int, | ||
expected_exception: type[Exception], | ||
): | ||
response = Mock() | ||
response.status_code = code | ||
mock_request.return_value = response | ||
with pytest.raises(expected_exception): | ||
rest.get_plans() |