-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_tracking_labels.py
More file actions
62 lines (40 loc) · 1.91 KB
/
test_tracking_labels.py
File metadata and controls
62 lines (40 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import responses
from scaup.utils.config import Config
SHIPMENT_REQUEST_CONTENTS = {"shipmentId": 1, "contact": {"a": "b", "c": "d"}}
SHIPMENT_CONTENTS = {"consignee_address_line_1": "test", "consignee_email": "test@diamond.ac.uk"}
@responses.activate
def test_get(client):
"""Should get tracking labels as a PDF"""
responses.get(f"{Config.shipping_service.backend_url}/api/shipment_requests/1/shipments/TO_FACILITY", status=404)
resp = client.get("/shipments/117/tracking-labels")
assert resp.status_code == 200
@responses.activate
def test_no_bar_code(client):
"""Should return 404 if bar code is not present"""
resp = client.get("/shipments/2/tracking-labels")
assert resp.status_code == 404
@responses.activate
def test_no_top_level_containers(client):
"""Should return 404 if shipment has no top level containers"""
resp = client.get("/shipments/118/tracking-labels")
assert resp.status_code == 404
@responses.activate
def test_user_address(client):
"""Should return include to/from address if these are available"""
responses.get(
f"{Config.shipping_service.backend_url}/api/shipment_requests/1/shipments/TO_FACILITY",
json=SHIPMENT_REQUEST_CONTENTS,
)
responses.get(f"{Config.shipping_service.backend_url}/api/shipments/1", json=SHIPMENT_CONTENTS, status=200)
resp = client.get("/shipments/117/tracking-labels")
assert resp.status_code == 200
@responses.activate
def test_user_address_no_consignee(client):
"""Should raise exception if shipment service returns 'from' address but no 'to' address"""
responses.get(
f"{Config.shipping_service.backend_url}/api/shipment_requests/1/shipments/TO_FACILITY",
json=SHIPMENT_REQUEST_CONTENTS,
)
responses.get(f"{Config.shipping_service.backend_url}/api/shipments/1", status=404)
resp = client.get("/shipments/117/tracking-labels")
assert resp.status_code == 424