Skip to content

Commit

Permalink
feat: gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
lchen-2101 committed Sep 12, 2023
1 parent a24c15b commit 7d2ca0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
from http import HTTPStatus
from typing import Annotated
from pprint import pprint
from fastapi import Depends, HTTPException, Request
from sqlalchemy.ext.asyncio import AsyncSession

Expand Down
4 changes: 3 additions & 1 deletion tests/entities/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ async def transaction_session(session_generator: async_scoped_session):
async with session_generator() as session:
yield session


@pytest.fixture(scope="function")
async def query_session(session_generator: async_scoped_session):
async with session_generator() as session:
yield session


@pytest.fixture(scope="function")
def session_generator(engine: AsyncEngine):
return async_scoped_session(
async_sessionmaker(engine, expire_on_commit=False), current_task
)
)
24 changes: 18 additions & 6 deletions tests/entities/repos/test_institutions_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,32 @@ async def test_get_institutions_by_domain(self, query_session: AsyncSession):
res = await repo.get_institutions(query_session, domain="test.bank")
assert len(res) == 1

async def test_get_institutions_by_domain_not_existing(self, query_session: AsyncSession):
async def test_get_institutions_by_domain_not_existing(
self, query_session: AsyncSession
):
res = await repo.get_institutions(query_session, domain="testing.bank")
assert len(res) == 0

async def test_add_institution(self, transaction_session: AsyncSession):
await repo.upsert_institution(
transaction_session, FinancialInstitutionDao(name="New Bank 123", lei="NEWBANK123")
transaction_session,
FinancialInstitutionDao(name="New Bank 123", lei="NEWBANK123"),
)
res = await repo.get_institutions(transaction_session)
assert len(res) == 2

async def test_update_institution(self, transaction_session: AsyncSession):
await repo.upsert_institution(
transaction_session, FinancialInstitutionDao(name="Test Bank 234", lei="TESTBANK123")
transaction_session,
FinancialInstitutionDao(name="Test Bank 234", lei="TESTBANK123"),
)
res = await repo.get_institutions(transaction_session)
assert len(res) == 1
assert res[0].name == "Test Bank 234"

async def test_add_domains(self, transaction_session: AsyncSession, query_session: AsyncSession):
async def test_add_domains(
self, transaction_session: AsyncSession, query_session: AsyncSession
):
await repo.add_domains(
transaction_session,
"TESTBANK123",
Expand All @@ -66,5 +72,11 @@ async def test_domain_allowed(self, transaction_session: AsyncSession):
denied_domain = DeniedDomainDao(domain="yahoo.com")
transaction_session.add(denied_domain)
await transaction_session.commit()
assert await repo.is_email_domain_allowed(transaction_session, "[email protected]") is False
assert await repo.is_email_domain_allowed(transaction_session, "[email protected]") is True
assert (
await repo.is_email_domain_allowed(transaction_session, "[email protected]")
is False
)
assert (
await repo.is_email_domain_allowed(transaction_session, "[email protected]")
is True
)

0 comments on commit 7d2ca0f

Please sign in to comment.