Skip to content

Commit e19848f

Browse files
committed
fix all the tests to use bootstrap or do right number of orm starts
1 parent 60577d6 commit e19848f

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

tests/integration/test_email.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,24 @@
22
import uuid
33
import pytest
44
import requests
5-
from allocation import config
5+
6+
from allocation import bootstrap, config
67
from allocation.domain import commands
78
from allocation.adapters import notifications
8-
from allocation.service_layer import messagebus, unit_of_work
99

1010
cfg = config.get_email_host_and_port()
1111

1212
@pytest.fixture
1313
def bus(sqlite_session_factory):
14-
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
15-
bus = messagebus.MessageBus(
16-
uow=uow,
14+
return bootstrap.bootstrap(
15+
start_orm=lambda: None,
16+
session_factory=sqlite_session_factory,
1717
notifications=notifications.EmailNotifications(
1818
smtp_host=cfg['host'],
1919
port=cfg['port'],
2020
),
2121
publish=lambda *_, **__: None
2222
)
23-
uow.bus = bus
24-
return bus
2523

2624

2725
def random_sku():

tests/integration/test_repository.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from allocation.adapters import repository
22
from allocation.domain import model
33

4+
45
def test_get_by_batchref(sqlite_session_factory):
56
session = sqlite_session_factory()
67
repo = repository.SqlAlchemyRepository(session)

tests/integration/test_views.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# pylint: disable=redefined-outer-name
22
from datetime import date
33
from unittest import mock
4+
from sqlalchemy.orm import clear_mappers
45
import pytest
5-
from allocation import views
6+
7+
from allocation import bootstrap, views
68
from allocation.domain import commands
7-
from allocation.service_layer import messagebus, unit_of_work
89

910

1011
@pytest.fixture
1112
def sqlite_bus(sqlite_session_factory):
12-
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
13-
bus = messagebus.MessageBus(
14-
uow=uow,
13+
bus = bootstrap.bootstrap(
14+
start_orm=lambda: None,
15+
session_factory=sqlite_session_factory,
1516
notifications=mock.Mock(),
1617
publish=mock.Mock(),
1718
)
18-
uow.bus = bus
19-
return bus
19+
yield bus
20+
clear_mappers()
2021

2122

2223
def test_allocations_view(sqlite_bus):

0 commit comments

Comments
 (0)