-
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.
Merge pull request #7 from The-Galley/develop
Release 0.2.2
- Loading branch information
Showing
18 changed files
with
106 additions
and
12 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
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,66 @@ | ||
from http import HTTPStatus | ||
|
||
import pytest | ||
from aiohttp.test_utils import TestClient | ||
from sqlalchemy import select | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
from yarl import URL | ||
|
||
from industry_game.db.models import User | ||
from industry_game.utils.users.base import UserType | ||
|
||
API_URL = URL("/api/v1/players/register/") | ||
|
||
|
||
async def test_player_register_successful_status_created( | ||
api_client: TestClient, | ||
): | ||
response = await api_client.post( | ||
API_URL, | ||
json={ | ||
"username": "username", | ||
"password": "password", | ||
"telegram": "telegram", | ||
"name": "your name", | ||
}, | ||
) | ||
assert response.status == HTTPStatus.CREATED | ||
|
||
|
||
async def test_player_register_successful_check_db( | ||
api_client: TestClient, | ||
session: AsyncSession, | ||
): | ||
await api_client.post( | ||
API_URL, | ||
json={ | ||
"username": "username", | ||
"password": "password", | ||
"telegram": "telegram", | ||
"name": "your name", | ||
}, | ||
) | ||
user = ( | ||
await session.scalars(select(User).where(User.username == "username")) | ||
).one() | ||
|
||
assert user.username == "username" | ||
assert user.type == UserType.PLAYER | ||
|
||
|
||
@pytest.mark.parametrize("user_type", (UserType.ADMIN, UserType.PLAYER)) | ||
async def test_player_register_same_username_error_conflict( | ||
api_client: TestClient, create_user, user_type | ||
): | ||
user = await create_user(type=user_type) | ||
|
||
response = await api_client.post( | ||
API_URL, | ||
json={ | ||
"username": user.username, | ||
"password": "password", | ||
"telegram": "telegram", | ||
"name": "your name", | ||
}, | ||
) | ||
assert response.status == HTTPStatus.BAD_REQUEST |
File renamed without changes.
File renamed without changes.
File renamed without changes.