karrio-server-graph 2026.1.1__py3-none-any.whl → 2026.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- karrio/server/graph/migrations/0003_remove_template_customs.py +15 -0
- karrio/server/graph/models.py +2 -5
- karrio/server/graph/schemas/base/__init__.py +68 -48
- karrio/server/graph/schemas/base/inputs.py +286 -71
- karrio/server/graph/schemas/base/mutations.py +365 -84
- karrio/server/graph/schemas/base/types.py +940 -248
- karrio/server/graph/serializers.py +35 -60
- karrio/server/graph/tests/base.py +33 -6
- karrio/server/graph/tests/test_carrier_connections.py +33 -4
- karrio/server/graph/tests/test_pickups.py +333 -0
- karrio/server/graph/tests/test_rate_sheets.py +0 -1
- karrio/server/graph/tests/test_templates.py +328 -510
- karrio/server/graph/utils.py +68 -1
- {karrio_server_graph-2026.1.1.dist-info → karrio_server_graph-2026.1.4.dist-info}/METADATA +1 -1
- {karrio_server_graph-2026.1.1.dist-info → karrio_server_graph-2026.1.4.dist-info}/RECORD +17 -15
- {karrio_server_graph-2026.1.1.dist-info → karrio_server_graph-2026.1.4.dist-info}/WHEEL +1 -1
- {karrio_server_graph-2026.1.1.dist-info → karrio_server_graph-2026.1.4.dist-info}/top_level.txt +0 -0
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
from unittest.mock import ANY
|
|
2
2
|
from karrio.server.graph.tests.base import GraphTestCase
|
|
3
3
|
import karrio.server.manager.models as manager
|
|
4
|
-
import karrio.server.graph.models as graph
|
|
5
4
|
|
|
6
5
|
|
|
7
|
-
class
|
|
8
|
-
def
|
|
6
|
+
class TestAddress(GraphTestCase):
|
|
7
|
+
def _create_address(self):
|
|
9
8
|
return self.query(
|
|
10
9
|
"""
|
|
11
|
-
mutation
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
mutation create_address($data: CreateAddressInput!) {
|
|
11
|
+
create_address(input: $data) {
|
|
12
|
+
address {
|
|
14
13
|
id
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
validation
|
|
30
|
-
validate_location
|
|
31
|
-
}
|
|
14
|
+
meta
|
|
15
|
+
company_name
|
|
16
|
+
person_name
|
|
17
|
+
address_line1
|
|
18
|
+
address_line2
|
|
19
|
+
postal_code
|
|
20
|
+
residential
|
|
21
|
+
city
|
|
22
|
+
state_code
|
|
23
|
+
country_code
|
|
24
|
+
email
|
|
25
|
+
phone_number
|
|
26
|
+
validation
|
|
27
|
+
validate_location
|
|
32
28
|
}
|
|
33
29
|
errors {
|
|
34
30
|
field
|
|
@@ -37,40 +33,37 @@ class TestAddressTemplate(GraphTestCase):
|
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
""",
|
|
40
|
-
operation_name="
|
|
41
|
-
variables=
|
|
36
|
+
operation_name="create_address",
|
|
37
|
+
variables=ADDRESS_DATA,
|
|
42
38
|
)
|
|
43
39
|
|
|
44
|
-
def
|
|
45
|
-
response = self.
|
|
40
|
+
def test_create_address(self):
|
|
41
|
+
response = self._create_address()
|
|
46
42
|
self.assertResponseNoErrors(response)
|
|
47
|
-
self.assertDictEqual(response.data,
|
|
43
|
+
self.assertDictEqual(response.data, ADDRESS_RESPONSE)
|
|
48
44
|
|
|
49
|
-
def
|
|
50
|
-
|
|
45
|
+
def test_update_address(self):
|
|
46
|
+
address = self._create_address().data
|
|
51
47
|
response = self.query(
|
|
52
48
|
"""
|
|
53
|
-
mutation
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
mutation update_address($data: UpdateAddressInput!) {
|
|
50
|
+
update_address(input: $data) {
|
|
51
|
+
address {
|
|
56
52
|
id
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
validation
|
|
72
|
-
validate_location
|
|
73
|
-
}
|
|
53
|
+
meta
|
|
54
|
+
company_name
|
|
55
|
+
person_name
|
|
56
|
+
address_line1
|
|
57
|
+
address_line2
|
|
58
|
+
postal_code
|
|
59
|
+
residential
|
|
60
|
+
city
|
|
61
|
+
state_code
|
|
62
|
+
country_code
|
|
63
|
+
email
|
|
64
|
+
phone_number
|
|
65
|
+
validation
|
|
66
|
+
validate_location
|
|
74
67
|
}
|
|
75
68
|
errors {
|
|
76
69
|
field
|
|
@@ -79,62 +72,56 @@ class TestAddressTemplate(GraphTestCase):
|
|
|
79
72
|
}
|
|
80
73
|
}
|
|
81
74
|
""",
|
|
82
|
-
operation_name="
|
|
75
|
+
operation_name="update_address",
|
|
83
76
|
variables={
|
|
84
77
|
"data": {
|
|
85
|
-
"id":
|
|
86
|
-
**
|
|
78
|
+
"id": address["data"]["create_address"]["address"]["id"],
|
|
79
|
+
**ADDRESS_UPDATE_DATA["data"],
|
|
87
80
|
},
|
|
88
81
|
},
|
|
89
82
|
)
|
|
90
|
-
response_data = response.data
|
|
91
83
|
|
|
92
84
|
self.assertResponseNoErrors(response)
|
|
93
|
-
self.assertDictEqual(
|
|
85
|
+
self.assertDictEqual(response.data, ADDRESS_UPDATE_RESPONSE)
|
|
94
86
|
|
|
95
|
-
def
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
def test_delete_address(self):
|
|
88
|
+
address = self._create_address().data
|
|
89
|
+
address_id = address["data"]["create_address"]["address"]["id"]
|
|
90
|
+
delete_data = {"data": {"id": address_id}}
|
|
99
91
|
response = self.query(
|
|
100
92
|
"""
|
|
101
|
-
mutation
|
|
102
|
-
|
|
93
|
+
mutation delete_address($data: DeleteMutationInput!) {
|
|
94
|
+
delete_address(input: $data) {
|
|
103
95
|
id
|
|
104
96
|
}
|
|
105
97
|
}
|
|
106
98
|
""",
|
|
107
|
-
operation_name="
|
|
108
|
-
variables=
|
|
99
|
+
operation_name="delete_address",
|
|
100
|
+
variables=delete_data,
|
|
109
101
|
)
|
|
110
|
-
response_data = response.data
|
|
111
102
|
|
|
112
103
|
self.assertResponseNoErrors(response)
|
|
113
|
-
self.assertEqual(
|
|
114
|
-
self.assertEqual(len(graph.Template.objects.all()), 0)
|
|
104
|
+
self.assertEqual(response.data["data"]["delete_address"]["id"], address_id)
|
|
115
105
|
self.assertEqual(len(manager.Address.objects.all()), 0)
|
|
116
106
|
|
|
117
107
|
|
|
118
|
-
class
|
|
119
|
-
def
|
|
108
|
+
class TestParcel(GraphTestCase):
|
|
109
|
+
def _create_parcel(self):
|
|
120
110
|
return self.query(
|
|
121
111
|
"""
|
|
122
|
-
mutation
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
mutation create_parcel($data: CreateParcelInput!) {
|
|
113
|
+
create_parcel(input: $data) {
|
|
114
|
+
parcel {
|
|
125
115
|
id
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
packaging_type
|
|
136
|
-
package_preset
|
|
137
|
-
}
|
|
116
|
+
meta
|
|
117
|
+
width
|
|
118
|
+
height
|
|
119
|
+
length
|
|
120
|
+
dimension_unit
|
|
121
|
+
weight
|
|
122
|
+
weight_unit
|
|
123
|
+
packaging_type
|
|
124
|
+
package_preset
|
|
138
125
|
}
|
|
139
126
|
errors {
|
|
140
127
|
field
|
|
@@ -143,37 +130,33 @@ class TestParcelTemplate(GraphTestCase):
|
|
|
143
130
|
}
|
|
144
131
|
}
|
|
145
132
|
""",
|
|
146
|
-
operation_name="
|
|
147
|
-
variables=
|
|
133
|
+
operation_name="create_parcel",
|
|
134
|
+
variables=PARCEL_DATA,
|
|
148
135
|
)
|
|
149
136
|
|
|
150
|
-
def
|
|
151
|
-
response = self.
|
|
152
|
-
response_data = response.data
|
|
137
|
+
def test_create_parcel(self):
|
|
138
|
+
response = self._create_parcel()
|
|
153
139
|
|
|
154
140
|
self.assertResponseNoErrors(response)
|
|
155
|
-
self.assertDictEqual(
|
|
141
|
+
self.assertDictEqual(response.data, PARCEL_RESPONSE)
|
|
156
142
|
|
|
157
|
-
def
|
|
158
|
-
|
|
143
|
+
def test_update_parcel(self):
|
|
144
|
+
parcel = self._create_parcel().data
|
|
159
145
|
response = self.query(
|
|
160
146
|
"""
|
|
161
|
-
mutation
|
|
162
|
-
|
|
163
|
-
|
|
147
|
+
mutation update_parcel($data: UpdateParcelInput!) {
|
|
148
|
+
update_parcel(input: $data) {
|
|
149
|
+
parcel {
|
|
164
150
|
id
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
packaging_type
|
|
175
|
-
package_preset
|
|
176
|
-
}
|
|
151
|
+
meta
|
|
152
|
+
width
|
|
153
|
+
height
|
|
154
|
+
length
|
|
155
|
+
dimension_unit
|
|
156
|
+
weight
|
|
157
|
+
weight_unit
|
|
158
|
+
packaging_type
|
|
159
|
+
package_preset
|
|
177
160
|
}
|
|
178
161
|
errors {
|
|
179
162
|
field
|
|
@@ -182,496 +165,331 @@ class TestParcelTemplate(GraphTestCase):
|
|
|
182
165
|
}
|
|
183
166
|
}
|
|
184
167
|
""",
|
|
185
|
-
operation_name="
|
|
168
|
+
operation_name="update_parcel",
|
|
186
169
|
variables={
|
|
187
170
|
"data": {
|
|
188
|
-
"id":
|
|
189
|
-
**
|
|
171
|
+
"id": parcel["data"]["create_parcel"]["parcel"]["id"],
|
|
172
|
+
**PARCEL_UPDATE_DATA["data"],
|
|
190
173
|
},
|
|
191
174
|
},
|
|
192
175
|
)
|
|
193
|
-
response_data = response.data
|
|
194
176
|
|
|
195
177
|
self.assertResponseNoErrors(response)
|
|
196
|
-
self.assertDictEqual(
|
|
178
|
+
self.assertDictEqual(response.data, PARCEL_UPDATE_RESPONSE)
|
|
197
179
|
|
|
198
|
-
def
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
180
|
+
def test_delete_parcel(self):
|
|
181
|
+
parcel = self._create_parcel().data
|
|
182
|
+
parcel_id = parcel["data"]["create_parcel"]["parcel"]["id"]
|
|
183
|
+
delete_data = {"data": {"id": parcel_id}}
|
|
202
184
|
response = self.query(
|
|
203
185
|
"""
|
|
204
|
-
mutation
|
|
205
|
-
|
|
186
|
+
mutation delete_parcel($data: DeleteMutationInput!) {
|
|
187
|
+
delete_parcel(input: $data) {
|
|
206
188
|
id
|
|
207
189
|
}
|
|
208
190
|
}
|
|
209
191
|
""",
|
|
210
|
-
operation_name="
|
|
211
|
-
variables=
|
|
192
|
+
operation_name="delete_parcel",
|
|
193
|
+
variables=delete_data,
|
|
212
194
|
)
|
|
213
|
-
response_data = response.data
|
|
214
195
|
|
|
215
196
|
self.assertResponseNoErrors(response)
|
|
216
|
-
self.assertEqual(
|
|
217
|
-
self.assertEqual(len(graph.Template.objects.all()), 0)
|
|
197
|
+
self.assertEqual(response.data["data"]["delete_parcel"]["id"], parcel_id)
|
|
218
198
|
self.assertEqual(len(manager.Parcel.objects.all()), 0)
|
|
219
199
|
|
|
220
200
|
|
|
221
|
-
|
|
222
|
-
def _create_customs_info_template(self):
|
|
223
|
-
return self.query(
|
|
224
|
-
"""
|
|
225
|
-
mutation create_customs_template($data: CreateCustomsTemplateInput!) {
|
|
226
|
-
create_customs_template(input: $data) {
|
|
227
|
-
template {
|
|
228
|
-
id
|
|
229
|
-
label
|
|
230
|
-
is_default
|
|
231
|
-
customs {
|
|
232
|
-
incoterm
|
|
233
|
-
content_type
|
|
234
|
-
commercial_invoice
|
|
235
|
-
content_description
|
|
236
|
-
duty {
|
|
237
|
-
paid_by
|
|
238
|
-
currency
|
|
239
|
-
account_number
|
|
240
|
-
declared_value
|
|
241
|
-
bill_to {
|
|
242
|
-
company_name
|
|
243
|
-
person_name
|
|
244
|
-
address_line1
|
|
245
|
-
address_line2
|
|
246
|
-
postal_code
|
|
247
|
-
residential
|
|
248
|
-
city
|
|
249
|
-
state_code
|
|
250
|
-
country_code
|
|
251
|
-
email
|
|
252
|
-
phone_number
|
|
253
|
-
validation
|
|
254
|
-
validate_location
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
invoice
|
|
258
|
-
signer
|
|
259
|
-
certify
|
|
260
|
-
commodities {
|
|
261
|
-
id
|
|
262
|
-
sku
|
|
263
|
-
weight
|
|
264
|
-
quantity
|
|
265
|
-
weight_unit
|
|
266
|
-
description
|
|
267
|
-
value_amount
|
|
268
|
-
value_currency
|
|
269
|
-
origin_country
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
errors {
|
|
274
|
-
field
|
|
275
|
-
messages
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
""",
|
|
280
|
-
operation_name="create_customs_template",
|
|
281
|
-
variables=CUSTOMS_TEMPLATE_DATA,
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
def test_create_customs_info_template(self):
|
|
285
|
-
response = self._create_customs_info_template()
|
|
286
|
-
response_data = response.data
|
|
287
|
-
|
|
288
|
-
self.assertResponseNoErrors(response)
|
|
289
|
-
self.assertDictEqual(response_data, CUSTOMS_TEMPLATE_RESPONSE)
|
|
290
|
-
|
|
291
|
-
def test_update_customs_info_template(self):
|
|
292
|
-
template = self._create_customs_info_template().data
|
|
293
|
-
CUSTOMS_TEMPLATE_UPDATE_DATA["data"]["id"] = template["data"][
|
|
294
|
-
"create_customs_template"
|
|
295
|
-
]["template"]["id"]
|
|
296
|
-
CUSTOMS_TEMPLATE_UPDATE_DATA["data"]["customs"]["commodities"][0]["id"] = next(
|
|
297
|
-
c["id"]
|
|
298
|
-
for c in template["data"]["create_customs_template"]["template"]["customs"][
|
|
299
|
-
"commodities"
|
|
300
|
-
]
|
|
301
|
-
if c["sku"]
|
|
302
|
-
== template["data"]["create_customs_template"]["template"]["customs"][
|
|
303
|
-
"commodities"
|
|
304
|
-
][0]["sku"]
|
|
305
|
-
)
|
|
306
|
-
|
|
307
|
-
response = self.query(
|
|
308
|
-
"""
|
|
309
|
-
mutation update_customs_template($data: UpdateCustomsTemplateInput!) {
|
|
310
|
-
update_customs_template(input: $data) {
|
|
311
|
-
template {
|
|
312
|
-
id
|
|
313
|
-
is_default
|
|
314
|
-
label
|
|
315
|
-
customs {
|
|
316
|
-
incoterm
|
|
317
|
-
content_type
|
|
318
|
-
commercial_invoice
|
|
319
|
-
content_description
|
|
320
|
-
duty {
|
|
321
|
-
paid_by
|
|
322
|
-
currency
|
|
323
|
-
account_number
|
|
324
|
-
declared_value
|
|
325
|
-
bill_to {
|
|
326
|
-
company_name
|
|
327
|
-
person_name
|
|
328
|
-
address_line1
|
|
329
|
-
address_line2
|
|
330
|
-
postal_code
|
|
331
|
-
residential
|
|
332
|
-
city
|
|
333
|
-
state_code
|
|
334
|
-
country_code
|
|
335
|
-
email
|
|
336
|
-
phone_number
|
|
337
|
-
validation
|
|
338
|
-
validate_location
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
invoice
|
|
342
|
-
signer
|
|
343
|
-
certify
|
|
344
|
-
commodities {
|
|
345
|
-
id
|
|
346
|
-
sku
|
|
347
|
-
weight
|
|
348
|
-
quantity
|
|
349
|
-
weight_unit
|
|
350
|
-
description
|
|
351
|
-
value_amount
|
|
352
|
-
value_currency
|
|
353
|
-
origin_country
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
errors {
|
|
358
|
-
field
|
|
359
|
-
messages
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
""",
|
|
364
|
-
operation_name="update_customs_template",
|
|
365
|
-
variables=CUSTOMS_TEMPLATE_UPDATE_DATA,
|
|
366
|
-
)
|
|
367
|
-
response_data = response.data
|
|
368
|
-
|
|
369
|
-
self.assertResponseNoErrors(response)
|
|
370
|
-
self.assertDictEqual(response_data, CUSTOMS_TEMPLATE_UPDATE_RESPONSE)
|
|
371
|
-
|
|
372
|
-
def test_delete_customs_info(self):
|
|
373
|
-
template = self._create_customs_info_template().data
|
|
374
|
-
template_id = template["data"]["create_customs_template"]["template"]["id"]
|
|
375
|
-
delete_template_data = {"data": {"id": template_id}}
|
|
376
|
-
response = self.query(
|
|
377
|
-
"""
|
|
378
|
-
mutation delete_template($data: DeleteMutationInput!) {
|
|
379
|
-
delete_template(input: $data) {
|
|
380
|
-
id
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
""",
|
|
384
|
-
operation_name="delete_template",
|
|
385
|
-
variables=delete_template_data,
|
|
386
|
-
)
|
|
387
|
-
response_data = response.data
|
|
388
|
-
|
|
389
|
-
self.assertResponseNoErrors(response)
|
|
390
|
-
self.assertEqual(response_data["data"]["delete_template"]["id"], template_id)
|
|
391
|
-
self.assertEqual(len(graph.Template.objects.all()), 0)
|
|
392
|
-
self.assertEqual(len(manager.Customs.objects.all()), 0)
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
ADDRESS_TEMPLATE_DATA = {
|
|
201
|
+
ADDRESS_DATA = {
|
|
396
202
|
"data": {
|
|
397
|
-
"
|
|
398
|
-
"
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
"state_code": "NB",
|
|
408
|
-
},
|
|
203
|
+
"address_line1": "125 Church St",
|
|
204
|
+
"person_name": "John Doe",
|
|
205
|
+
"company_name": "A corp.",
|
|
206
|
+
"phone_number": "514 000 0000",
|
|
207
|
+
"city": "Moncton",
|
|
208
|
+
"country_code": "CA",
|
|
209
|
+
"postal_code": "E1C4Z8",
|
|
210
|
+
"residential": False,
|
|
211
|
+
"state_code": "NB",
|
|
212
|
+
"meta": {"label": "Warehouse"},
|
|
409
213
|
}
|
|
410
214
|
}
|
|
411
215
|
|
|
412
|
-
|
|
216
|
+
ADDRESS_RESPONSE = {
|
|
413
217
|
"data": {
|
|
414
|
-
"
|
|
415
|
-
"
|
|
218
|
+
"create_address": {
|
|
219
|
+
"address": {
|
|
416
220
|
"id": ANY,
|
|
417
|
-
"is_default": False,
|
|
418
|
-
"
|
|
419
|
-
"
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
"validation": None,
|
|
432
|
-
"validate_location": None,
|
|
433
|
-
},
|
|
221
|
+
"meta": {"label": "Warehouse", "is_default": False},
|
|
222
|
+
"company_name": "A corp.",
|
|
223
|
+
"person_name": "John Doe",
|
|
224
|
+
"address_line1": "125 Church St",
|
|
225
|
+
"address_line2": None,
|
|
226
|
+
"postal_code": "E1C4Z8",
|
|
227
|
+
"residential": False,
|
|
228
|
+
"city": "Moncton",
|
|
229
|
+
"state_code": "NB",
|
|
230
|
+
"country_code": "CA",
|
|
231
|
+
"email": None,
|
|
232
|
+
"phone_number": "+1 514-000-0000",
|
|
233
|
+
"validation": None,
|
|
234
|
+
"validate_location": None,
|
|
434
235
|
},
|
|
435
236
|
"errors": None,
|
|
436
237
|
}
|
|
437
238
|
}
|
|
438
239
|
}
|
|
439
240
|
|
|
440
|
-
|
|
241
|
+
ADDRESS_UPDATE_DATA = {
|
|
441
242
|
"data": {
|
|
442
|
-
"
|
|
443
|
-
"
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
"person_name": "John Moe",
|
|
447
|
-
},
|
|
243
|
+
"city": "Moncton",
|
|
244
|
+
"email": "test@gmail.com",
|
|
245
|
+
"person_name": "John Moe",
|
|
246
|
+
"meta": {"label": "Warehouse Update"},
|
|
448
247
|
}
|
|
449
248
|
}
|
|
450
249
|
|
|
451
|
-
|
|
250
|
+
ADDRESS_UPDATE_RESPONSE = {
|
|
452
251
|
"data": {
|
|
453
|
-
"
|
|
454
|
-
"
|
|
252
|
+
"update_address": {
|
|
253
|
+
"address": {
|
|
455
254
|
"id": ANY,
|
|
456
|
-
"
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
},
|
|
471
|
-
"id": ANY,
|
|
472
|
-
"is_default": False,
|
|
473
|
-
"label": "Warehouse Update",
|
|
255
|
+
"meta": {"label": "Warehouse Update", "is_default": False},
|
|
256
|
+
"address_line1": "125 Church St",
|
|
257
|
+
"address_line2": None,
|
|
258
|
+
"city": "Moncton",
|
|
259
|
+
"company_name": "A corp.",
|
|
260
|
+
"country_code": "CA",
|
|
261
|
+
"email": "test@gmail.com",
|
|
262
|
+
"person_name": "John Moe",
|
|
263
|
+
"phone_number": "+1 514-000-0000",
|
|
264
|
+
"postal_code": "E1C4Z8",
|
|
265
|
+
"residential": False,
|
|
266
|
+
"state_code": "NB",
|
|
267
|
+
"validate_location": None,
|
|
268
|
+
"validation": None,
|
|
474
269
|
},
|
|
475
270
|
"errors": None,
|
|
476
271
|
}
|
|
477
272
|
}
|
|
478
273
|
}
|
|
479
274
|
|
|
480
|
-
|
|
275
|
+
PARCEL_DATA = {
|
|
481
276
|
"data": {
|
|
482
|
-
"
|
|
483
|
-
"
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
"package_preset": "canadapost_corrugated_small_box",
|
|
487
|
-
},
|
|
277
|
+
"weight": 1,
|
|
278
|
+
"weight_unit": "KG",
|
|
279
|
+
"package_preset": "canadapost_corrugated_small_box",
|
|
280
|
+
"meta": {"label": "Purple Pack"},
|
|
488
281
|
}
|
|
489
282
|
}
|
|
490
283
|
|
|
491
|
-
|
|
284
|
+
PARCEL_RESPONSE = {
|
|
492
285
|
"data": {
|
|
493
|
-
"
|
|
286
|
+
"create_parcel": {
|
|
494
287
|
"errors": None,
|
|
495
|
-
"
|
|
288
|
+
"parcel": {
|
|
496
289
|
"id": ANY,
|
|
497
|
-
"is_default": False,
|
|
498
|
-
"
|
|
499
|
-
"
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
"weight_unit": "KG",
|
|
507
|
-
"width": 42.0,
|
|
508
|
-
},
|
|
290
|
+
"meta": {"label": "Purple Pack", "is_default": False},
|
|
291
|
+
"dimension_unit": "CM",
|
|
292
|
+
"height": 32.0,
|
|
293
|
+
"length": 32.0,
|
|
294
|
+
"package_preset": "canadapost_corrugated_small_box",
|
|
295
|
+
"packaging_type": None,
|
|
296
|
+
"weight": 1.0,
|
|
297
|
+
"weight_unit": "KG",
|
|
298
|
+
"width": 42.0,
|
|
509
299
|
},
|
|
510
300
|
}
|
|
511
301
|
}
|
|
512
302
|
}
|
|
513
303
|
|
|
514
|
-
|
|
304
|
+
PARCEL_UPDATE_DATA = {
|
|
515
305
|
"data": {
|
|
516
|
-
"
|
|
517
|
-
|
|
518
|
-
"weight_unit": "LB",
|
|
519
|
-
}
|
|
306
|
+
"weight": 0.45,
|
|
307
|
+
"weight_unit": "LB",
|
|
520
308
|
}
|
|
521
309
|
}
|
|
522
310
|
|
|
523
|
-
|
|
311
|
+
PARCEL_UPDATE_RESPONSE = {
|
|
524
312
|
"data": {
|
|
525
|
-
"
|
|
313
|
+
"update_parcel": {
|
|
526
314
|
"errors": None,
|
|
527
|
-
"
|
|
315
|
+
"parcel": {
|
|
528
316
|
"id": ANY,
|
|
529
|
-
"is_default": False,
|
|
530
|
-
"
|
|
531
|
-
"
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
"weight_unit": "LB",
|
|
539
|
-
"width": 42.0,
|
|
540
|
-
},
|
|
317
|
+
"meta": {"label": "Purple Pack", "is_default": False},
|
|
318
|
+
"dimension_unit": "CM",
|
|
319
|
+
"height": 32.0,
|
|
320
|
+
"length": 32.0,
|
|
321
|
+
"package_preset": "canadapost_corrugated_small_box",
|
|
322
|
+
"packaging_type": None,
|
|
323
|
+
"weight": 0.45,
|
|
324
|
+
"weight_unit": "LB",
|
|
325
|
+
"width": 42.0,
|
|
541
326
|
},
|
|
542
327
|
}
|
|
543
328
|
}
|
|
544
329
|
}
|
|
545
330
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
"
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
{
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
331
|
+
|
|
332
|
+
class TestProduct(GraphTestCase):
|
|
333
|
+
def _create_product(self):
|
|
334
|
+
return self.query(
|
|
335
|
+
"""
|
|
336
|
+
mutation create_product($data: CreateProductInput!) {
|
|
337
|
+
create_product(input: $data) {
|
|
338
|
+
product {
|
|
339
|
+
id
|
|
340
|
+
meta
|
|
341
|
+
weight
|
|
342
|
+
weight_unit
|
|
343
|
+
quantity
|
|
344
|
+
sku
|
|
345
|
+
title
|
|
346
|
+
hs_code
|
|
347
|
+
description
|
|
348
|
+
value_amount
|
|
349
|
+
value_currency
|
|
350
|
+
origin_country
|
|
351
|
+
}
|
|
352
|
+
errors {
|
|
353
|
+
field
|
|
354
|
+
messages
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
""",
|
|
359
|
+
operation_name="create_product",
|
|
360
|
+
variables=PRODUCT_DATA,
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
def test_create_product(self):
|
|
364
|
+
response = self._create_product()
|
|
365
|
+
|
|
366
|
+
self.assertResponseNoErrors(response)
|
|
367
|
+
self.assertDictEqual(response.data, PRODUCT_RESPONSE)
|
|
368
|
+
|
|
369
|
+
def test_update_product(self):
|
|
370
|
+
product = self._create_product().data
|
|
371
|
+
response = self.query(
|
|
372
|
+
"""
|
|
373
|
+
mutation update_product($data: UpdateProductInput!) {
|
|
374
|
+
update_product(input: $data) {
|
|
375
|
+
product {
|
|
376
|
+
id
|
|
377
|
+
meta
|
|
378
|
+
weight
|
|
379
|
+
weight_unit
|
|
380
|
+
quantity
|
|
381
|
+
sku
|
|
382
|
+
title
|
|
383
|
+
hs_code
|
|
384
|
+
description
|
|
385
|
+
value_amount
|
|
386
|
+
value_currency
|
|
387
|
+
origin_country
|
|
388
|
+
}
|
|
389
|
+
errors {
|
|
390
|
+
field
|
|
391
|
+
messages
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
""",
|
|
396
|
+
operation_name="update_product",
|
|
397
|
+
variables={
|
|
398
|
+
"data": {
|
|
399
|
+
"id": product["data"]["create_product"]["product"]["id"],
|
|
400
|
+
**PRODUCT_UPDATE_DATA["data"],
|
|
559
401
|
},
|
|
560
|
-
|
|
561
|
-
|
|
402
|
+
},
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
self.assertResponseNoErrors(response)
|
|
406
|
+
self.assertDictEqual(response.data, PRODUCT_UPDATE_RESPONSE)
|
|
407
|
+
|
|
408
|
+
def test_delete_product(self):
|
|
409
|
+
product = self._create_product().data
|
|
410
|
+
product_id = product["data"]["create_product"]["product"]["id"]
|
|
411
|
+
delete_data = {"data": {"id": product_id}}
|
|
412
|
+
response = self.query(
|
|
413
|
+
"""
|
|
414
|
+
mutation delete_product($data: DeleteMutationInput!) {
|
|
415
|
+
delete_product(input: $data) {
|
|
416
|
+
id
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
""",
|
|
420
|
+
operation_name="delete_product",
|
|
421
|
+
variables=delete_data,
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
self.assertResponseNoErrors(response)
|
|
425
|
+
self.assertEqual(response.data["data"]["delete_product"]["id"], product_id)
|
|
426
|
+
self.assertEqual(len(manager.Commodity.objects.filter(meta__label__isnull=False)), 0)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
PRODUCT_DATA = {
|
|
430
|
+
"data": {
|
|
431
|
+
"weight": 1.5,
|
|
432
|
+
"weight_unit": "KG",
|
|
433
|
+
"quantity": 1,
|
|
434
|
+
"sku": "TEST-SKU-001",
|
|
435
|
+
"title": "Test Product Title",
|
|
436
|
+
"hs_code": "123456",
|
|
437
|
+
"description": "A test product",
|
|
438
|
+
"value_amount": 99.99,
|
|
439
|
+
"value_currency": "USD",
|
|
440
|
+
"origin_country": "US",
|
|
441
|
+
"meta": {"label": "Test Product"},
|
|
562
442
|
}
|
|
563
443
|
}
|
|
564
444
|
|
|
565
|
-
|
|
445
|
+
PRODUCT_RESPONSE = {
|
|
566
446
|
"data": {
|
|
567
|
-
"
|
|
568
|
-
"
|
|
447
|
+
"create_product": {
|
|
448
|
+
"errors": None,
|
|
449
|
+
"product": {
|
|
569
450
|
"id": ANY,
|
|
570
|
-
"label": "
|
|
571
|
-
"
|
|
572
|
-
"
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
"commodities": [
|
|
582
|
-
{
|
|
583
|
-
"id": ANY,
|
|
584
|
-
"sku": "6787L8K7J8L7J8L7K8",
|
|
585
|
-
"weight": 1.15,
|
|
586
|
-
"quantity": 1,
|
|
587
|
-
"weight_unit": "KG",
|
|
588
|
-
"description": None,
|
|
589
|
-
"value_amount": None,
|
|
590
|
-
"value_currency": None,
|
|
591
|
-
"origin_country": None,
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
"id": ANY,
|
|
595
|
-
"sku": "3PO4I5J4PO5I4HI5OH",
|
|
596
|
-
"weight": 0.75,
|
|
597
|
-
"quantity": 4,
|
|
598
|
-
"weight_unit": "KG",
|
|
599
|
-
"description": None,
|
|
600
|
-
"value_amount": None,
|
|
601
|
-
"value_currency": None,
|
|
602
|
-
"origin_country": None,
|
|
603
|
-
},
|
|
604
|
-
],
|
|
605
|
-
},
|
|
451
|
+
"meta": {"label": "Test Product", "is_default": False},
|
|
452
|
+
"weight": 1.5,
|
|
453
|
+
"weight_unit": "KG",
|
|
454
|
+
"quantity": 1,
|
|
455
|
+
"sku": "TEST-SKU-001",
|
|
456
|
+
"title": "Test Product Title",
|
|
457
|
+
"hs_code": "123456",
|
|
458
|
+
"description": "A test product",
|
|
459
|
+
"value_amount": 99.99,
|
|
460
|
+
"value_currency": "USD",
|
|
461
|
+
"origin_country": "US",
|
|
606
462
|
},
|
|
607
|
-
"errors": None,
|
|
608
463
|
}
|
|
609
464
|
}
|
|
610
465
|
}
|
|
611
466
|
|
|
612
|
-
|
|
467
|
+
PRODUCT_UPDATE_DATA = {
|
|
613
468
|
"data": {
|
|
614
|
-
"
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
"weight": 1,
|
|
618
|
-
"weight_unit": "LB",
|
|
619
|
-
}
|
|
620
|
-
],
|
|
621
|
-
"duty": {"paid_by": "sender"},
|
|
622
|
-
}
|
|
469
|
+
"weight": 2.0,
|
|
470
|
+
"title": "Updated Title",
|
|
471
|
+
"meta": {"label": "Updated Product"},
|
|
623
472
|
}
|
|
624
473
|
}
|
|
625
474
|
|
|
626
|
-
|
|
475
|
+
PRODUCT_UPDATE_RESPONSE = {
|
|
627
476
|
"data": {
|
|
628
|
-
"
|
|
629
|
-
"
|
|
477
|
+
"update_product": {
|
|
478
|
+
"errors": None,
|
|
479
|
+
"product": {
|
|
630
480
|
"id": ANY,
|
|
631
|
-
"is_default": False,
|
|
632
|
-
"
|
|
633
|
-
"
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
"declared_value": None,
|
|
643
|
-
"bill_to": None,
|
|
644
|
-
},
|
|
645
|
-
"invoice": None,
|
|
646
|
-
"signer": None,
|
|
647
|
-
"certify": None,
|
|
648
|
-
"commodities": [
|
|
649
|
-
{
|
|
650
|
-
"id": ANY,
|
|
651
|
-
"sku": "6787L8K7J8L7J8L7K8",
|
|
652
|
-
"weight": 1.0,
|
|
653
|
-
"quantity": 1,
|
|
654
|
-
"weight_unit": "LB",
|
|
655
|
-
"description": None,
|
|
656
|
-
"value_amount": None,
|
|
657
|
-
"value_currency": None,
|
|
658
|
-
"origin_country": None,
|
|
659
|
-
},
|
|
660
|
-
{
|
|
661
|
-
"id": ANY,
|
|
662
|
-
"sku": "3PO4I5J4PO5I4HI5OH",
|
|
663
|
-
"weight": 0.75,
|
|
664
|
-
"quantity": 4,
|
|
665
|
-
"weight_unit": "KG",
|
|
666
|
-
"description": None,
|
|
667
|
-
"value_amount": None,
|
|
668
|
-
"value_currency": None,
|
|
669
|
-
"origin_country": None,
|
|
670
|
-
},
|
|
671
|
-
],
|
|
672
|
-
},
|
|
481
|
+
"meta": {"label": "Updated Product", "is_default": False},
|
|
482
|
+
"weight": 2.0,
|
|
483
|
+
"weight_unit": "KG",
|
|
484
|
+
"quantity": 1,
|
|
485
|
+
"sku": "TEST-SKU-001",
|
|
486
|
+
"title": "Updated Title",
|
|
487
|
+
"hs_code": "123456",
|
|
488
|
+
"description": "A test product",
|
|
489
|
+
"value_amount": 99.99,
|
|
490
|
+
"value_currency": "USD",
|
|
491
|
+
"origin_country": "US",
|
|
673
492
|
},
|
|
674
|
-
"errors": None,
|
|
675
493
|
}
|
|
676
494
|
}
|
|
677
495
|
}
|