Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
slimovich committed Jun 29, 2020
1 parent 7737561 commit 9621b45
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ fastapi = "==0.58.1"
uvicorn = "==0.11.5"
gunicorn = "==20.0.4"
alembic = "==1.4.1"
inject = "==4.1.2"
pydantic = {extras = ["email"],version = "==1.5.1"}
entrypoints = "==0.3"
psycopg2 = "*"
Expand Down
9 changes: 1 addition & 8 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ Overview
----------
This repository contains a skeleton app which can be used to speed-up your next project.

- **Fast-API:** Application with gino, async ORM
- **Fast-API:** Application with gino, async ORM, Dependencies injection
- **hexagonal architecture:** Bettre code organisation
- **Pipenv:** Package manager (Also creating virtual environement)
- **inject:** Python library for Dependencies injection
- **JWT:** Token authentication.
- **Gino:** Async ORM used with AsyncPG and postgreSQL
- **Alembic:** Database migrations
Expand Down
17 changes: 8 additions & 9 deletions tests/api/test_user_router.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from typing import Any

import inject
import pytest
from fastapi import FastAPI
from starlette import status
from starlette.testclient import TestClient

from src.api.api import api_router
from src.api.utils import get_user_services
from src.domain.userManagment.schema.user import UserDBSchema
from src.domain.userManagment.service.userService import UserService
from src.infrastructure.database.models.user import UserModel


Expand Down Expand Up @@ -38,11 +37,11 @@ async def create_user(self, user: Any) -> UserModel:
return USER_MODEL


@pytest.fixture
def injector() -> None:
inject.clear_and_configure(
lambda binder: binder.bind(UserService, UserServiceDummy()) # type: ignore
)
def get_user_services_dummy() -> UserServiceDummy:
return UserServiceDummy()


app.dependency_overrides[get_user_services] = get_user_services_dummy


@pytest.fixture
Expand All @@ -64,7 +63,7 @@ def user_schema() -> UserDBSchema:

class TestUserRouter:
def test_user_create_valide(
self, injector: None, user_model: UserModel, user_schema: UserDBSchema
self, user_model: UserModel, user_schema: UserDBSchema
) -> None:

response = client.post(
Expand All @@ -76,7 +75,7 @@ def test_user_create_valide(
"is_active": True,
"is_superuser": False,
"created_date": "1/1/2020",
},
}
)
assert response.status_code == status.HTTP_200_OK
assert response.json() == user_schema.__dict__

0 comments on commit 9621b45

Please sign in to comment.