-
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.
- Loading branch information
1 parent
0b94ab0
commit d48eb9a
Showing
5 changed files
with
86 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
import pytest | ||
from pydantic import BaseModel | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
|
||
from osrs_bot_detector_db.repositories.label_repository import LabelRepository | ||
from osrs_bot_detector_db.schemas.label import LabelCreate | ||
from osrs_bot_detector_db.schemas.label import LabelCreate, LabelResponse, LabelUpdate | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_create_label(session: AsyncSession): | ||
async with session as db_session: | ||
label_repo = LabelRepository(db_session=db_session) | ||
label_create = LabelCreate(label="tester") | ||
label_repo = LabelRepository(db_session=session) | ||
await label_repo.create(model=LabelCreate(label="Tester")) | ||
|
||
await label_repo.create(label_create) | ||
|
||
@pytest.mark.asyncio | ||
async def test_read_label(session: AsyncSession): | ||
label_repo = LabelRepository(db_session=session) | ||
label = await label_repo.request(label="Tester") | ||
print(f"{label=}") | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_update_label(session: AsyncSession): | ||
# label_crud = LabelRepository(db_session=session) | ||
# create_model = LabelCreate(label="OldLabel") | ||
|
||
# created_label = await label_crud.create(model=create_model) | ||
|
||
# update_model = LabelUpdate(label="NewLabel") | ||
# updated_label = await label_crud.update( | ||
# id_value=created_label.id, model=update_model | ||
# ) | ||
|
||
# assert updated_label is not None | ||
# assert updated_label.label == "NewLabel" | ||
|
||
|
||
# @pytest.mark.asyncio | ||
# async def test_delete_label(session: AsyncSession): | ||
# label_crud = LabelRepository(db_session=session) | ||
# create_model = LabelCreate(label="DeleteMe") | ||
|
||
# created_label = await label_crud.create(model=create_model) | ||
|
||
# deletion_success = await label_crud.delete(id_value=created_label.id) | ||
|
||
# assert deletion_success is True | ||
|
||
# # Ensure the label is actually deleted | ||
# try: | ||
# await label_crud.read(label="DeleteMe") | ||
# assert False, "Label was not deleted" | ||
# except Exception: | ||
# 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