Ejemplo n.º 1
0
 def test_for_new_product(self):
     uow = FakeUnitOfWork()
     handlers.add_batch("b1", "CRUNCHY-ARMCHAIR", 100, None, uow)
     messagebus.handle(
         events.BatchCreated("b1", "CRUNCHY-ARMCHAIR", 100, None), uow)
     assert uow.products.get("CRUNCHY-ARMCHAIR") is not None
     assert uow.committed
Ejemplo n.º 2
0
 def test_returns_allocation(self):
     uow = FakeUnitOfWork()
     handlers.add_batch("b1", "COMPLICATED-LAMP", 100, None, uow)
     results = handlers.allocate("o1", "COMPLICATED-LAMP", 100, None, uow)
     messagebus.handle(
         events.BatchCreated("batch1", "COMPLICATED-LAMP", 100, None), uow)
     result = messagebus.handle(
         events.AllocationRequired("o1", "COMPLICATED-LAMP", 10), uow)
     assert result == "batch1"
Ejemplo n.º 3
0
def add_batch(
    validated_data: AddBatch  # from call abstract.py
) -> None:
    batch = handlers.add_batch(command.AddBatch(
        sku=validated_data.sku,
        batch_ref=validated_data.batch_ref,
        quantity=validated_data.quantity,
        manufacture_date=validated_data.manufacture_date,
        expire_date=validated_data.expire_date
    ))   #
    repo = BatchRepository()  # replace batchrepo to batchUow
    repo.add(batch)
Ejemplo n.º 4
0
def test_add_batch():
    uow = FakeUnitOfWork()
    handlers.add_batch("b1", "CRUNCHY-ARMCHAIR", 100, None, uow)
    assert uow.batches.get("b1") is not None
    assert uow.committed
Ejemplo n.º 5
0
def test_allocate_returns_allocation():
    uow = FakeUnitOfWork()
    handlers.add_batch("batch1", "COMPLICATED-LAMP", 100, None, uow)
    result = handlers.allocate("o1", "COMPLICATED-LAMP", 10, uow)
    assert result == "bach1"