Skip to content

Commit ce6f584

Browse files
committed
session_factory -> sqlite_session_factory (needs backport)
1 parent 7ac1cf4 commit ce6f584

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

tests/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def in_memory_db():
2323
return engine
2424

2525
@pytest.fixture
26-
def session_factory(in_memory_db):
26+
def sqlite_session_factory(in_memory_db):
2727
start_mappers()
2828
yield sessionmaker(bind=in_memory_db)
2929
clear_mappers()
3030

3131
@pytest.fixture
32-
def session(session_factory):
33-
return session_factory()
32+
def sqlite_session(sqlite_session_factory):
33+
return sqlite_session_factory()
3434

3535

3636
@retry(stop=stop_after_delay(10))

tests/integration/test_repository.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from allocation.adapters import repository
22
from allocation.domain import model
33

4-
def test_get_by_batchref(session):
5-
repo = repository.SqlAlchemyRepository(session)
4+
def test_get_by_batchref(sqlite_session):
5+
repo = repository.SqlAlchemyRepository(sqlite_session)
66
b1 = model.Batch(ref='b1', sku='sku1', qty=100, eta=None)
77
b2 = model.Batch(ref='b2', sku='sku1', qty=100, eta=None)
88
b3 = model.Batch(ref='b3', sku='sku2', qty=100, eta=None)

tests/integration/test_uow.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def get_allocated_batch_ref(session, orderid, sku):
3434
return batchref
3535

3636

37-
def test_uow_can_retrieve_a_batch_and_allocate_to_it(session_factory):
38-
session = session_factory()
37+
def test_uow_can_retrieve_a_batch_and_allocate_to_it(sqlite_session_factory):
38+
session = sqlite_session_factory()
3939
insert_batch(session, 'batch1', 'HIPSTER-WORKBENCH', 100, None)
4040
session.commit()
4141

42-
uow = unit_of_work.SqlAlchemyUnitOfWork(session_factory)
42+
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
4343
with uow:
4444
product = uow.products.get(sku='HIPSTER-WORKBENCH')
4545
line = model.OrderLine('o1', 'HIPSTER-WORKBENCH', 10)
@@ -50,27 +50,27 @@ def test_uow_can_retrieve_a_batch_and_allocate_to_it(session_factory):
5050
assert batchref == 'batch1'
5151

5252

53-
def test_rolls_back_uncommitted_work_by_default(session_factory):
54-
uow = unit_of_work.SqlAlchemyUnitOfWork(session_factory)
53+
def test_rolls_back_uncommitted_work_by_default(sqlite_session_factory):
54+
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
5555
with uow:
5656
insert_batch(uow.session, 'batch1', 'MEDIUM-PLINTH', 100, None)
5757

58-
new_session = session_factory()
58+
new_session = sqlite_session_factory()
5959
rows = list(new_session.execute('SELECT * FROM "batches"'))
6060
assert rows == []
6161

6262

63-
def test_rolls_back_on_error(session_factory):
63+
def test_rolls_back_on_error(sqlite_session_factory):
6464
class MyException(Exception):
6565
pass
6666

67-
uow = unit_of_work.SqlAlchemyUnitOfWork(session_factory)
67+
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
6868
with pytest.raises(MyException):
6969
with uow:
7070
insert_batch(uow.session, 'batch1', 'LARGE-FORK', 100, None)
7171
raise MyException()
7272

73-
new_session = session_factory()
73+
new_session = sqlite_session_factory()
7474
rows = list(new_session.execute('SELECT * FROM "batches"'))
7575
assert rows == []
7676

0 commit comments

Comments
 (0)