-
Notifications
You must be signed in to change notification settings - Fork 8
/
conftest.py
93 lines (80 loc) · 2.18 KB
/
conftest.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os
import pytest
import responses
from spree import Spree
@pytest.fixture
def fp():
def wrapper(rel_path):
"return the full path of given rel_path"
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
rel_path
)
)
return wrapper
@pytest.fixture
def spree():
return Spree('http://mystore/api', 'some-key')
@pytest.yield_fixture
def resp(fp):
rsps = responses.RequestsMock(False)
rsps.start()
"Products"
rsps.add(
responses.GET,
'http://mystore/api/products',
body=open(fp('responses/products.json'), 'r').read()
)
rsps.add(
responses.GET,
'http://mystore/api/products/2',
body=open(fp('responses/product-2.json'), 'r').read()
)
"Orders"
rsps.add(
responses.GET,
'http://mystore/api/orders',
body=open(fp('responses/orders.json'), 'r').read()
)
rsps.add(
responses.GET,
'http://mystore/api/orders/R123456789',
body=open(fp('responses/order-R123456789.json'), 'r').read()
)
"StockItems"
rsps.add(
responses.GET,
'http://mystore/api/stock_locations/1/stock_items',
body=open(fp('responses/stock_items.json'), 'r').read()
)
rsps.add(
responses.GET,
'http://mystore/api/stock_locations/1/stock_items/4',
body=open(fp('responses/stock_item-4.json'), 'r').read()
)
"Variants"
rsps.add(
responses.GET,
'http://mystore/api/products/ruby-on-rails-jr-spaghetti/variants',
body=open(fp('responses/variant-ROR-00013.json'), 'r').read()
)
rsps.add(
responses.GET,
'http://mystore/api/variants',
body=open(fp('responses/variant-ROR-00013.json'), 'r').read()
)
"Stock Locations"
rsps.add(
responses.GET,
'http://mystore/api/stock_locations',
body=open(fp('responses/stock_locations.json'), 'r').read()
)
rsps.add(
responses.GET,
'http://mystore/api/stock_locations/1',
body=open(fp('responses/stock_location-1.json'), 'r').read()
)
yield rsps
rsps.stop()
rsps.reset()