|
| 1 | +from commercetools.platform.models import order |
| 2 | + |
| 3 | + |
| 4 | +def test_deserialize_order_paged_query_response(): |
| 5 | + response = order.OrderPagedQueryResponse.deserialize( |
| 6 | + { |
| 7 | + "limit": 20, |
| 8 | + "offset": 0, |
| 9 | + "count": 20, |
| 10 | + "total": 612, |
| 11 | + "results": [ |
| 12 | + { |
| 13 | + "type": "Order", |
| 14 | + "id": "c28ba890-0595-475f-8c8b-ca96d7c5c602", |
| 15 | + "version": 4, |
| 16 | + "lastMessageSequenceNumber": 4, |
| 17 | + "createdAt": "2020-12-17T12:45:22.407Z", |
| 18 | + "lastModifiedAt": "2021-01-18T09:07:07.198Z", |
| 19 | + "lastModifiedBy": { |
| 20 | + "isPlatformClient": True, |
| 21 | + "user": { |
| 22 | + "typeId": "user", |
| 23 | + "id": "cf8fd14f-384d-4a13-a81a-fdb1fc76623a", |
| 24 | + }, |
| 25 | + }, |
| 26 | + "createdBy": { |
| 27 | + "clientId": "1qGcTSsoGLHvmiRUnMOut5__", |
| 28 | + "isPlatformClient": False, |
| 29 | + "anonymousId": "75c0fe8c-d4b8-40b2-9138-a39278acf406", |
| 30 | + }, |
| 31 | + "orderNumber": "5000158", |
| 32 | + "customerEmail": "test@example.org", |
| 33 | + "anonymousId": "75c0fe8c-d4b8-40b2-9138-a39278acf406", |
| 34 | + "locale": "nl-NL", |
| 35 | + "totalPrice": { |
| 36 | + "type": "centPrecision", |
| 37 | + "currencyCode": "EUR", |
| 38 | + "centAmount": 5716, |
| 39 | + "fractionDigits": 2, |
| 40 | + }, |
| 41 | + "taxedPrice": { |
| 42 | + "totalNet": { |
| 43 | + "type": "centPrecision", |
| 44 | + "currencyCode": "EUR", |
| 45 | + "centAmount": 4724, |
| 46 | + "fractionDigits": 2, |
| 47 | + }, |
| 48 | + "totalGross": { |
| 49 | + "type": "centPrecision", |
| 50 | + "currencyCode": "EUR", |
| 51 | + "centAmount": 5716, |
| 52 | + "fractionDigits": 2, |
| 53 | + }, |
| 54 | + "taxPortions": [ |
| 55 | + { |
| 56 | + "rate": 0.21, |
| 57 | + "amount": { |
| 58 | + "type": "centPrecision", |
| 59 | + "currencyCode": "EUR", |
| 60 | + "centAmount": 992, |
| 61 | + "fractionDigits": 2, |
| 62 | + }, |
| 63 | + "name": "21% BTW", |
| 64 | + } |
| 65 | + ], |
| 66 | + }, |
| 67 | + "country": "NL", |
| 68 | + "orderState": "Confirmed", |
| 69 | + "paymentState": "Pending", |
| 70 | + "syncInfo": [], |
| 71 | + "returnInfo": [], |
| 72 | + "shippingInfo": { |
| 73 | + "shippingMethodName": "Standard shipping method", |
| 74 | + "price": { |
| 75 | + "type": "centPrecision", |
| 76 | + "currencyCode": "EUR", |
| 77 | + "centAmount": 5000, |
| 78 | + "fractionDigits": 2, |
| 79 | + }, |
| 80 | + "shippingRate": { |
| 81 | + "price": { |
| 82 | + "type": "centPrecision", |
| 83 | + "currencyCode": "EUR", |
| 84 | + "centAmount": 5000, |
| 85 | + "fractionDigits": 2, |
| 86 | + }, |
| 87 | + "freeAbove": { |
| 88 | + "type": "centPrecision", |
| 89 | + "currencyCode": "EUR", |
| 90 | + "centAmount": 50000, |
| 91 | + "fractionDigits": 2, |
| 92 | + }, |
| 93 | + "tiers": [], |
| 94 | + }, |
| 95 | + "taxRate": { |
| 96 | + "name": "21% BTW", |
| 97 | + "amount": 0.21, |
| 98 | + "includedInPrice": True, |
| 99 | + "country": "NL", |
| 100 | + "id": "Z0wLUuYw", |
| 101 | + "subRates": [], |
| 102 | + }, |
| 103 | + "taxCategory": { |
| 104 | + "typeId": "tax-category", |
| 105 | + "id": "ac8b6c6c-424f-4cbb-aec5-d3754fb8dd78", |
| 106 | + }, |
| 107 | + "deliveries": [], |
| 108 | + "shippingMethod": { |
| 109 | + "typeId": "shipping-method", |
| 110 | + "id": "fdf53457-487f-4b0e-bfbb-3124e44686e7", |
| 111 | + }, |
| 112 | + "taxedPrice": { |
| 113 | + "totalNet": { |
| 114 | + "type": "centPrecision", |
| 115 | + "currencyCode": "EUR", |
| 116 | + "centAmount": 4132, |
| 117 | + "fractionDigits": 2, |
| 118 | + }, |
| 119 | + "totalGross": { |
| 120 | + "type": "centPrecision", |
| 121 | + "currencyCode": "EUR", |
| 122 | + "centAmount": 5000, |
| 123 | + "fractionDigits": 2, |
| 124 | + }, |
| 125 | + }, |
| 126 | + "shippingMethodState": "MatchesCart", |
| 127 | + }, |
| 128 | + "taxMode": "Platform", |
| 129 | + "inventoryMode": "ReserveOnOrder", |
| 130 | + "taxRoundingMode": "HalfEven", |
| 131 | + "taxCalculationMode": "LineItemLevel", |
| 132 | + "origin": "Customer", |
| 133 | + "lineItems": [ |
| 134 | + { |
| 135 | + "id": "7c0e2cbf-3434-494a-89cb-6fc0f8881662", |
| 136 | + "productId": "02e00188-0f19-4b43-9c35-55ae702fd1be", |
| 137 | + "name": {"nl-NL": "Some Product"}, |
| 138 | + "productType": { |
| 139 | + "typeId": "product-type", |
| 140 | + "id": "109caecb-abe6-4900-ab03-7af5af985ff3", |
| 141 | + "version": 1, |
| 142 | + }, |
| 143 | + "productSlug": {"nl-NL": "some-product"}, |
| 144 | + "variant": { |
| 145 | + "id": 1, |
| 146 | + "sku": "PRODUCT1", |
| 147 | + "key": "PRODUCT1", |
| 148 | + "prices": [ |
| 149 | + { |
| 150 | + "value": { |
| 151 | + "type": "centPrecision", |
| 152 | + "currencyCode": "EUR", |
| 153 | + "centAmount": 895, |
| 154 | + "fractionDigits": 2, |
| 155 | + }, |
| 156 | + "id": "36506ccc-e770-4937-a027-3e4ff0e7e70e", |
| 157 | + "channel": { |
| 158 | + "typeId": "channel", |
| 159 | + "id": "d75c2a23-fb85-4916-bd9c-9862dca9138c", |
| 160 | + }, |
| 161 | + "discounted": { |
| 162 | + "value": { |
| 163 | + "type": "centPrecision", |
| 164 | + "currencyCode": "EUR", |
| 165 | + "centAmount": 716, |
| 166 | + "fractionDigits": 2, |
| 167 | + }, |
| 168 | + "discount": { |
| 169 | + "typeId": "product-discount", |
| 170 | + "id": "57b26c6e-ebea-4197-ac24-ed602d1a0c04", |
| 171 | + }, |
| 172 | + }, |
| 173 | + } |
| 174 | + ], |
| 175 | + "images": [ |
| 176 | + { |
| 177 | + "url": "http://example.org/image.jpg", |
| 178 | + "dimensions": {"w": 1200, "h": 800}, |
| 179 | + }, |
| 180 | + ], |
| 181 | + "attributes": [ |
| 182 | + {"name": "brand", "value": {"nl-NL": "SomeBrand"}}, |
| 183 | + ], |
| 184 | + "assets": [], |
| 185 | + "availability": { |
| 186 | + "channels": { |
| 187 | + "d75c2a23-fb85-4916-bd9c-9862dca9138c": { |
| 188 | + "isOnStock": False, |
| 189 | + "restockableInDays": 12, |
| 190 | + "availableQuantity": -1, |
| 191 | + } |
| 192 | + } |
| 193 | + }, |
| 194 | + }, |
| 195 | + "price": { |
| 196 | + "value": { |
| 197 | + "type": "centPrecision", |
| 198 | + "currencyCode": "EUR", |
| 199 | + "centAmount": 895, |
| 200 | + "fractionDigits": 2, |
| 201 | + }, |
| 202 | + "id": "36506ccc-e770-4937-a027-3e4ff0e7e70e", |
| 203 | + "channel": { |
| 204 | + "typeId": "channel", |
| 205 | + "id": "d75c2a23-fb85-4916-bd9c-9862dca9138c", |
| 206 | + }, |
| 207 | + "discounted": { |
| 208 | + "value": { |
| 209 | + "type": "centPrecision", |
| 210 | + "currencyCode": "EUR", |
| 211 | + "centAmount": 716, |
| 212 | + "fractionDigits": 2, |
| 213 | + }, |
| 214 | + "discount": { |
| 215 | + "typeId": "product-discount", |
| 216 | + "id": "57b26c6e-ebea-4197-ac24-ed602d1a0c04", |
| 217 | + }, |
| 218 | + }, |
| 219 | + }, |
| 220 | + "quantity": 1, |
| 221 | + "discountedPricePerQuantity": [], |
| 222 | + "supplyChannel": { |
| 223 | + "typeId": "channel", |
| 224 | + "id": "d75c2a23-fb85-4916-bd9c-9862dca9138c", |
| 225 | + }, |
| 226 | + "distributionChannel": { |
| 227 | + "typeId": "channel", |
| 228 | + "id": "d75c2a23-fb85-4916-bd9c-9862dca9138c", |
| 229 | + }, |
| 230 | + "taxRate": { |
| 231 | + "name": "21% BTW", |
| 232 | + "amount": 0.21, |
| 233 | + "includedInPrice": True, |
| 234 | + "country": "NL", |
| 235 | + "id": "Z0wLUuYw", |
| 236 | + "subRates": [], |
| 237 | + }, |
| 238 | + "addedAt": "2020-12-17T12:43:22.773Z", |
| 239 | + "lastModifiedAt": "2020-12-17T12:43:22.773Z", |
| 240 | + "state": [ |
| 241 | + { |
| 242 | + "quantity": 1, |
| 243 | + "state": { |
| 244 | + "typeId": "state", |
| 245 | + "id": "f1d9531d-41f0-46a7-82f2-c4b0748aa9f5", |
| 246 | + }, |
| 247 | + } |
| 248 | + ], |
| 249 | + "priceMode": "Platform", |
| 250 | + "totalPrice": { |
| 251 | + "type": "centPrecision", |
| 252 | + "currencyCode": "EUR", |
| 253 | + "centAmount": 716, |
| 254 | + "fractionDigits": 2, |
| 255 | + }, |
| 256 | + "taxedPrice": { |
| 257 | + "totalNet": { |
| 258 | + "type": "centPrecision", |
| 259 | + "currencyCode": "EUR", |
| 260 | + "centAmount": 592, |
| 261 | + "fractionDigits": 2, |
| 262 | + }, |
| 263 | + "totalGross": { |
| 264 | + "type": "centPrecision", |
| 265 | + "currencyCode": "EUR", |
| 266 | + "centAmount": 716, |
| 267 | + "fractionDigits": 2, |
| 268 | + }, |
| 269 | + }, |
| 270 | + "lineItemMode": "Standard", |
| 271 | + } |
| 272 | + ], |
| 273 | + "customLineItems": [], |
| 274 | + "transactionFee": True, |
| 275 | + "discountCodes": [], |
| 276 | + "cart": { |
| 277 | + "typeId": "cart", |
| 278 | + "id": "a25425a1-f557-44a6-b2ab-c06f5134bb99", |
| 279 | + }, |
| 280 | + "custom": { |
| 281 | + "type": { |
| 282 | + "typeId": "type", |
| 283 | + "id": "05ce0769-40bf-4246-a72a-7a5064e49cd1", |
| 284 | + }, |
| 285 | + "fields": { |
| 286 | + "customerNotes": "<p>🔥</p>\n👍", |
| 287 | + "dateOfBirth": "1919-12-31", |
| 288 | + }, |
| 289 | + }, |
| 290 | + "paymentInfo": { |
| 291 | + "payments": [ |
| 292 | + { |
| 293 | + "typeId": "payment", |
| 294 | + "id": "5b8e9bbe-a6dd-47cf-bc16-1f81d8c0e9dd", |
| 295 | + } |
| 296 | + ] |
| 297 | + }, |
| 298 | + "shippingAddress": {"country": "NL"}, |
| 299 | + "billingAddress": { |
| 300 | + "firstName": "is", |
| 301 | + "lastName": "emoji accepted", |
| 302 | + "streetName": "sdafsdf", |
| 303 | + "streetNumber": "11111111111111111111111111111111111111111111111111111111111111111111", |
| 304 | + "postalCode": "1234hh", |
| 305 | + "city": "sdffd", |
| 306 | + "country": "NL", |
| 307 | + "company": "", |
| 308 | + "building": "", |
| 309 | + "phone": "06123456789", |
| 310 | + }, |
| 311 | + "itemShippingAddresses": [], |
| 312 | + "refusedGifts": [], |
| 313 | + "store": {"typeId": "store", "key": "store"}, |
| 314 | + }, |
| 315 | + ], |
| 316 | + } |
| 317 | + ) |
0 commit comments