Skip to content

Commit 63988f2

Browse files
committed
Merge repository get tests
1 parent 4defff7 commit 63988f2

File tree

2 files changed

+14
-73
lines changed

2 files changed

+14
-73
lines changed

tests/repository/sync/test_get.py

Lines changed: 0 additions & 59 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33

4-
async def test_get_returns_model(repository_class, model_class, sa_manager):
4+
async def test_get_returns_model(repository_class, model_class, sa_bind, sync_async_wrapper):
55
model = model_class(
66
model_id=1,
77
name="Someone",
@@ -10,16 +10,16 @@ async def test_get_returns_model(repository_class, model_class, sa_manager):
1010
model_id=2,
1111
name="SomeoneElse",
1212
)
13-
repo = repository_class(sa_manager.get_bind())
14-
await repo.save_many({model, model2})
13+
repo = repository_class(bind=sa_bind, model_class=model_class)
14+
await sync_async_wrapper(repo.save_many({model, model2}))
1515

16-
result = await repo.get(1)
16+
result = await sync_async_wrapper(repo.get(1))
1717
assert result.model_id == 1
1818
assert result.name == "Someone"
1919
assert isinstance(result, model_class)
2020

2121

22-
async def test_get_many_returns_models(repository_class, model_class, sa_manager):
22+
async def test_get_many_returns_models(repository_class, model_class, sa_bind, sync_async_wrapper):
2323
model = model_class(
2424
model_id=1,
2525
name="Someone",
@@ -32,28 +32,28 @@ async def test_get_many_returns_models(repository_class, model_class, sa_manager
3232
model_id=3,
3333
name="StillSomeoneElse",
3434
)
35-
repo = repository_class(sa_manager.get_bind())
36-
await repo.save_many({model, model2, model3})
35+
repo = repository_class(bind=sa_bind, model_class=model_class)
36+
await sync_async_wrapper(repo.save_many({model, model2, model3}))
3737

38-
result = await repo.get_many([1, 2])
38+
result = await sync_async_wrapper(repo.get_many([1, 2]))
3939
assert isinstance(result, list)
4040
assert len(result) == 2
4141
assert result[0].model_id == 1
4242
assert result[1].model_id == 2
4343

4444

4545
async def test_get_many_returns_empty_list_if_nothing_found(
46-
repository_class, model_class, sa_manager
46+
repository_class, model_class, sa_bind, sync_async_wrapper
4747
):
48-
repo = repository_class(sa_manager.get_bind())
48+
repo = repository_class(bind=sa_bind, model_class=model_class)
4949

50-
result = await repo.get_many([1, 2])
50+
result = await sync_async_wrapper(repo.get_many([1, 2]))
5151
assert isinstance(result, list)
5252
assert len(result) == 0
5353

5454

55-
async def test_get_raises_exception_if_not_found(repository_class, sa_manager):
56-
repo = repository_class(sa_manager.get_bind())
55+
async def test_get_raises_exception_if_not_found(repository_class, model_class, sa_bind, sync_async_wrapper):
56+
repo = repository_class(bind=sa_bind, model_class=model_class)
5757

5858
with pytest.raises(Exception):
59-
await repo.get(3)
59+
await sync_async_wrapper(repo.get(3))

0 commit comments

Comments
 (0)