Skip to content

Commit b537364

Browse files
committed
strip out unecessary tests from e2e layer [fewer_e2e_tests]
1 parent cf2f52b commit b537364

File tree

1 file changed

+2
-38
lines changed

1 file changed

+2
-38
lines changed

test_api.py

+2-38
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def random_orderid(name=""):
2222

2323

2424
@pytest.mark.usefixtures("restart_api")
25-
def test_api_returns_allocation(add_stock):
25+
def test_happy_path_returns_201_and_allocated_batch(add_stock):
2626
sku, othersku = random_sku(), random_sku("other")
2727
earlybatch = random_batchref(1)
2828
laterbatch = random_batchref(2)
@@ -44,43 +44,7 @@ def test_api_returns_allocation(add_stock):
4444

4545

4646
@pytest.mark.usefixtures("restart_api")
47-
def test_allocations_are_persisted(add_stock):
48-
sku = random_sku()
49-
batch1, batch2 = random_batchref(1), random_batchref(2)
50-
order1, order2 = random_orderid(1), random_orderid(2)
51-
add_stock(
52-
[(batch1, sku, 10, "2011-01-01"), (batch2, sku, 10, "2011-01-02"),]
53-
)
54-
line1 = {"orderid": order1, "sku": sku, "qty": 10}
55-
line2 = {"orderid": order2, "sku": sku, "qty": 10}
56-
url = config.get_api_url()
57-
58-
# first order uses up all stock in batch 1
59-
r = requests.post(f"{url}/allocate", json=line1)
60-
assert r.status_code == 201
61-
assert r.json()["batchref"] == batch1
62-
63-
# second order should go to batch 2
64-
r = requests.post(f"{url}/allocate", json=line2)
65-
assert r.status_code == 201
66-
assert r.json()["batchref"] == batch2
67-
68-
69-
@pytest.mark.usefixtures("restart_api")
70-
def test_400_message_for_out_of_stock(add_stock):
71-
sku, smalL_batch, large_order = random_sku(), random_batchref(), random_orderid()
72-
add_stock(
73-
[(smalL_batch, sku, 10, "2011-01-01"),]
74-
)
75-
data = {"orderid": large_order, "sku": sku, "qty": 20}
76-
url = config.get_api_url()
77-
r = requests.post(f"{url}/allocate", json=data)
78-
assert r.status_code == 400
79-
assert r.json()["message"] == f"Out of stock for sku {sku}"
80-
81-
82-
@pytest.mark.usefixtures("restart_api")
83-
def test_400_message_for_invalid_sku():
47+
def test_unhappy_path_returns_400_and_error_message():
8448
unknown_sku, orderid = random_sku(), random_orderid()
8549
data = {"orderid": orderid, "sku": unknown_sku, "qty": 20}
8650
url = config.get_api_url()

0 commit comments

Comments
 (0)