1
1
#pylint: disable=unused-argument
2
2
from __future__ import annotations
3
3
from dataclasses import asdict
4
- from typing import TYPE_CHECKING
5
- from allocation .adapters import email , redis_eventpublisher
4
+ from typing import Callable , TYPE_CHECKING
6
5
from allocation .domain import commands , events , model
7
6
from allocation .domain .model import OrderLine
8
7
if TYPE_CHECKING :
@@ -38,6 +37,7 @@ def allocate(
38
37
product .allocate (line )
39
38
uow .commit ()
40
39
40
+
41
41
def reallocate (
42
42
event : events .Deallocated , uow : unit_of_work .AbstractUnitOfWork
43
43
):
@@ -46,6 +46,7 @@ def reallocate(
46
46
product .events .append (commands .Allocate (** asdict (event )))
47
47
uow .commit ()
48
48
49
+
49
50
def change_batch_quantity (
50
51
cmd : commands .ChangeBatchQuantity , uow : unit_of_work .AbstractUnitOfWork
51
52
):
@@ -58,18 +59,18 @@ def change_batch_quantity(
58
59
#pylint: disable=unused-argument
59
60
60
61
def send_out_of_stock_notification (
61
- event : events .OutOfStock , uow : unit_of_work . AbstractUnitOfWork ,
62
+ event : events .OutOfStock , send_mail : Callable ,
62
63
):
63
- email . send (
64
+ send_mail (
64
65
65
66
f'Out of stock for { event .sku } ' ,
66
67
)
67
68
68
69
69
70
def publish_allocated_event (
70
- event : events .Allocated , uow : unit_of_work . AbstractUnitOfWork ,
71
+ event : events .Allocated , publish : Callable ,
71
72
):
72
- redis_eventpublisher . publish ('line_allocated' , event )
73
+ publish ('line_allocated' , event )
73
74
74
75
75
76
def add_allocation_to_read_model (
@@ -83,6 +84,7 @@ def add_allocation_to_read_model(
83
84
)
84
85
uow .commit ()
85
86
87
+
86
88
def remove_allocation_from_read_model (
87
89
event : events .Deallocated , uow : unit_of_work .SqlAlchemyUnitOfWork ,
88
90
):
0 commit comments