Skip to content

Commit 800885b

Browse files
committed
add an extra test for update
1 parent cedfae3 commit 800885b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎test_repository.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,34 @@ def test_repository_can_retrieve_a_batch_with_allocations(session):
6565
assert retrieved._allocations == {
6666
model.OrderLine("order1", "GENERIC-SOFA", 12),
6767
}
68+
69+
70+
def get_allocations(session, batchid):
71+
rows = list(
72+
session.execute(
73+
"SELECT orderid"
74+
" FROM allocations"
75+
" JOIN order_lines ON allocations.orderline_id = order_lines.id"
76+
" JOIN batches ON allocations.batch_id = batches.id"
77+
" WHERE batches.reference = :batchid",
78+
dict(batchid=batchid),
79+
)
80+
)
81+
return {row[0] for row in rows}
82+
83+
84+
def test_updating_a_batch(session):
85+
order1 = model.OrderLine("order1", "WEATHERED-BENCH", 10)
86+
order2 = model.OrderLine("order2", "WEATHERED-BENCH", 20)
87+
batch = model.Batch("batch1", "WEATHERED-BENCH", 100, eta=None)
88+
batch.allocate(order1)
89+
90+
repo = repository.SqlAlchemyRepository(session)
91+
repo.add(batch)
92+
session.commit()
93+
94+
batch.allocate(order2)
95+
repo.add(batch)
96+
session.commit()
97+
98+
assert get_allocations(session, "batch1") == {"order1", "order2"}

0 commit comments

Comments
 (0)