Skip to content

Commit 58d05e4

Browse files
committed
first cut of orm, orderlines only [sqlalchemy_classical_mapper]
1 parent 3e9871d commit 58d05e4

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ dist: xenial
22
language: python
33
python: 3.8
44

5+
install:
6+
- pip3 install sqlalchemy
7+
58
script:
69
- make test
710

orm.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from sqlalchemy import Table, MetaData, Column, Integer, String
2+
from sqlalchemy.orm import mapper
3+
4+
import model
5+
6+
7+
metadata = MetaData()
8+
9+
order_lines = Table(
10+
"order_lines",
11+
metadata,
12+
Column("orderid", String(255), primary_key=True),
13+
Column("sku", String(255), primary_key=True),
14+
Column("qty", Integer),
15+
)
16+
17+
18+
def start_mappers():
19+
mapper(model.OrderLine, order_lines)

test_batches.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@ def make_batch_and_line(sku, batch_qty, line_qty):
1717
OrderLine("order-123", sku, line_qty),
1818
)
1919

20+
2021
def test_can_allocate_if_available_greater_than_required():
2122
large_batch, small_line = make_batch_and_line("ELEGANT-LAMP", 20, 2)
2223
assert large_batch.can_allocate(small_line)
2324

25+
2426
def test_cannot_allocate_if_available_smaller_than_required():
2527
small_batch, large_line = make_batch_and_line("ELEGANT-LAMP", 2, 20)
2628
assert small_batch.can_allocate(large_line) is False
2729

30+
2831
def test_can_allocate_if_available_equal_to_required():
2932
batch, line = make_batch_and_line("ELEGANT-LAMP", 2, 2)
3033
assert batch.can_allocate(line)
3134

35+
3236
def test_cannot_allocate_if_skus_do_not_match():
3337
batch = Batch("batch-001", "UNCOMFORTABLE-CHAIR", 100, eta=None)
3438
different_sku_line = OrderLine("order-123", "EXPENSIVE-TOASTER", 10)

0 commit comments

Comments
 (0)