File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import uuid
33import pytest
44import requests
5- from allocation import config
5+
6+ from allocation import bootstrap , config
67from allocation .domain import commands
78from allocation .adapters import notifications
8- from allocation .service_layer import messagebus , unit_of_work
99
1010cfg = config .get_email_host_and_port ()
1111
1212@pytest .fixture
1313def 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
2725def random_sku ():
Original file line number Diff line number Diff line change 11from allocation .adapters import repository
22from allocation .domain import model
33
4+
45def test_get_by_batchref (sqlite_session_factory ):
56 session = sqlite_session_factory ()
67 repo = repository .SqlAlchemyRepository (session )
Original file line number Diff line number Diff line change 11# pylint: disable=redefined-outer-name
22from datetime import date
33from unittest import mock
4+ from sqlalchemy .orm import clear_mappers
45import pytest
5- from allocation import views
6+
7+ from allocation import bootstrap , views
68from allocation .domain import commands
7- from allocation .service_layer import messagebus , unit_of_work
89
910
1011@pytest .fixture
1112def 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
2223def test_allocations_view (sqlite_bus ):
You can’t perform that action at this time.
0 commit comments