generated from MinBZK/python-project-template
-
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.
Bring code coverage back up and change pre-commit (#350)
- Loading branch information
Showing
17 changed files
with
460 additions
and
142 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import pytest | ||
from httpx import AsyncClient | ||
from pytest_mock import MockerFixture | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_auth_profile(client: AsyncClient, mocker: MockerFixture) -> None: | ||
mocker.patch("amt.api.routes.auth.get_user", return_value="test_user_for_auth_profile") | ||
response = await client.get("/auth/profile") | ||
|
||
assert b"https://gravatar.com/" in response.content |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from amt.api.ai_act_profile import ( | ||
AiActProfileItem, | ||
get_translation, | ||
) | ||
from babel.support import Translations | ||
|
||
|
||
def test_get_translation(): | ||
translation = Translations.load("amt/locale", locales="en") | ||
for item in AiActProfileItem: | ||
assert get_translation(item, translation) is not None | ||
# empty match | ||
assert get_translation(None, translation) is None # pyright: ignore |
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,12 @@ | ||
from amt.api.deps import custom_context_processor | ||
|
||
from tests.constants import default_fastapi_request | ||
|
||
|
||
def test_custom_context_processor(): | ||
result = custom_context_processor(default_fastapi_request()) | ||
assert result is not None | ||
assert result["version"] == "0.1.0" | ||
assert result["available_translations"] == ["en", "nl"] | ||
assert result["language"] == "en" | ||
assert result["translations"] is None |
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,13 @@ | ||
import pytest | ||
from amt.core.authorization import get_user | ||
from pytest_mock import MockerFixture | ||
|
||
|
||
@pytest.mark.asyncio | ||
def test_get_user(mocker: MockerFixture) -> None: | ||
mock_request = mocker.Mock(scope=["session"]) | ||
mock_request.session = {"user": {"name": "user"}} | ||
mock_get_requested_language = mocker.patch("amt.core.authorization.get_requested_language", return_value="nl") | ||
user = get_user(mock_request) | ||
assert user == {"name": "user", "locale": "nl"} | ||
mock_get_requested_language.assert_called_once_with(mock_request) |
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
Oops, something went wrong.