Skip to content

Commit e883f20

Browse files
committed
fixture to start mappers explicitly, use in repo and uow tests
1 parent f923760 commit e883f20

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

tests/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ def in_memory_sqlite_db():
2626

2727
@pytest.fixture
2828
def sqlite_session_factory(in_memory_sqlite_db):
29-
start_mappers()
3029
yield sessionmaker(bind=in_memory_sqlite_db)
30+
31+
32+
@pytest.fixture
33+
def mappers():
34+
start_mappers()
35+
yield
3136
clear_mappers()
3237

3338

@@ -57,9 +62,7 @@ def postgres_db():
5762

5863
@pytest.fixture
5964
def postgres_session_factory(postgres_db):
60-
start_mappers()
6165
yield sessionmaker(bind=postgres_db)
62-
clear_mappers()
6366

6467

6568
@pytest.fixture

tests/integration/test_repository.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import pytest
12
from allocation.adapters import repository
23
from allocation.domain import model
34

5+
pytestmark = pytest.mark.usefixtures("mappers")
6+
47

58
def test_get_by_batchref(sqlite_session_factory):
69
session = sqlite_session_factory()

tests/integration/test_uow.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import time
44
import traceback
55
from typing import List
6+
from unittest.mock import Mock
67
import pytest
78
from allocation.domain import model
89
from allocation.service_layer import unit_of_work
910
from ..random_refs import random_sku, random_batchref, random_orderid
1011

12+
pytestmark = pytest.mark.usefixtures("mappers")
13+
1114

1215
def insert_batch(session, ref, sku, qty, eta, product_version=1):
1316
session.execute(

0 commit comments

Comments
 (0)