-
Notifications
You must be signed in to change notification settings - Fork 0
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
6eb70e2
commit b7b58a5
Showing
5 changed files
with
73 additions
and
36 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
32 changes: 32 additions & 0 deletions
32
src/business_logic/formation/scrap/tests/unit/test_get_token_onisep.py
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,32 @@ | ||
import pytest | ||
from unittest.mock import patch | ||
from src.business_logic.formation.exceptions import NoOnisepAPIException | ||
|
||
from src.business_logic.formation.scrap.utils.get_onisep_token import ( | ||
get_token, | ||
) | ||
from src.constants.http_status_codes import HTTP_200_OK, HTTP_404_NOT_FOUND | ||
|
||
|
||
@pytest.fixture | ||
def mock_onisep_token(): | ||
with patch( | ||
"src.business_logic.formation.scrap.utils.get_onisep_token._send_request" | ||
) as mock_requests_get: | ||
yield mock_requests_get | ||
|
||
|
||
def test_get_token_success(mock_onisep_token): | ||
mock_onisep_token.return_value.status_code = HTTP_200_OK | ||
mock_onisep_token.return_value.json.return_value = {"token": "fake_token"} | ||
|
||
token = get_token() | ||
|
||
assert token == "Bearer fake_token" | ||
|
||
|
||
def test_get_token_failure(mock_onisep_token): | ||
mock_onisep_token.return_value.status_code = HTTP_404_NOT_FOUND | ||
|
||
with pytest.raises(NoOnisepAPIException): | ||
get_token() |
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