-
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.
feat(router): define dummy password generator router(#6)
* fix(workflows): fix pythonpath
- Loading branch information
Showing
14 changed files
with
69 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
-r requirements.txt | ||
httpx | ||
pytest | ||
pytest-asyncio | ||
pytest-cov |
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,5 @@ | ||
from fastapi import APIRouter | ||
|
||
router: APIRouter = APIRouter() | ||
|
||
from .password_generation_router import generate_password |
Empty file.
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,5 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class GeneratePasswordRequest(BaseModel): | ||
pass |
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,5 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class GeneratedPasswordResponse(BaseModel): | ||
password: str |
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,14 @@ | ||
from starlette import status | ||
|
||
from app.routers import router | ||
from app.routers.models.requests import GeneratePasswordRequest | ||
from app.routers.models.responses import GeneratedPasswordResponse | ||
|
||
|
||
@router.post( | ||
path='/generate/', | ||
status_code=status.HTTP_200_OK, | ||
response_model=GeneratedPasswordResponse, | ||
) | ||
async def generate_password(request: GeneratePasswordRequest) -> GeneratedPasswordResponse: | ||
return GeneratedPasswordResponse(password="something") |
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 @@ | ||
from typing import Generator | ||
|
||
import pytest | ||
from httpx import AsyncClient | ||
|
||
from app.main import app, SERVICE_NAME | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def mocked_client() -> Generator[AsyncClient, None, None]: | ||
yield AsyncClient(app=app, base_url=f'http://{SERVICE_NAME}:9001') |
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
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,19 @@ | ||
import pytest | ||
from httpx import AsyncClient | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_generate_password(mocked_client: AsyncClient): | ||
async with mocked_client as client: | ||
response = await client.post("/api/v1/passwords/generate/", json={}) | ||
|
||
assert response.status_code == 200 | ||
assert response.json() == {"password": "something"} | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_generate_password_but_input_is_not_valid(mocked_client: AsyncClient): | ||
async with mocked_client as client: | ||
response = await client.post("/api/v1/passwords/generate/", data={}) | ||
|
||
assert response.status_code == 422 |