|
204 | 204 | }
|
205 | 205 | """
|
206 | 206 |
|
| 207 | +retrieveInvoiceExample = """ |
| 208 | +{ |
| 209 | + "uuid": "inv_22910fc6-c931-48e7-ac12-90d2cb5f0059", |
| 210 | + "external_id": "INV0001", |
| 211 | + "date": "2015-11-01T00:00:00.000Z", |
| 212 | + "due_date": "2015-11-15T00:00:00.000Z", |
| 213 | + "currency": "USD", |
| 214 | + "line_items": [ |
| 215 | + { |
| 216 | + "uuid": "li_d72e6843-5793-41d0-bfdf-0269514c9c56", |
| 217 | + "external_id": null, |
| 218 | + "type": "subscription", |
| 219 | + "subscription_uuid": "sub_e6bc5407-e258-4de0-bb43-61faaf062035", |
| 220 | + "plan_uuid": "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", |
| 221 | + "prorated": false, |
| 222 | + "service_period_start": "2015-11-01T00:00:00.000Z", |
| 223 | + "service_period_end": "2015-12-01T00:00:00.000Z", |
| 224 | + "amount_in_cents": 5000, |
| 225 | + "quantity": 1, |
| 226 | + "discount_code": "PSO86", |
| 227 | + "discount_amount_in_cents": 1000, |
| 228 | + "tax_amount_in_cents": 900, |
| 229 | + "account_code": null |
| 230 | + }, |
| 231 | + { |
| 232 | + "uuid": "li_0cc8c112-beac-416d-af11-f35744ca4e83", |
| 233 | + "external_id": null, |
| 234 | + "type": "one_time", |
| 235 | + "description": "Setup Fees", |
| 236 | + "amount_in_cents": 2500, |
| 237 | + "quantity": 1, |
| 238 | + "discount_code": "PSO86", |
| 239 | + "discount_amount_in_cents": 500, |
| 240 | + "tax_amount_in_cents": 450, |
| 241 | + "account_code": null |
| 242 | + } |
| 243 | + ], |
| 244 | + "transactions": [ |
| 245 | + { |
| 246 | + "uuid": "tr_879d560a-1bec-41bb-986e-665e38a2f7bc", |
| 247 | + "external_id": null, |
| 248 | + "type": "payment", |
| 249 | + "date": "2015-11-05T00:14:23.000Z", |
| 250 | + "result": "successful" |
| 251 | + } |
| 252 | + ] |
| 253 | +} |
| 254 | +""" |
| 255 | + |
207 | 256 | class InvoiceTestCase(unittest.TestCase):
|
208 | 257 | """
|
209 | 258 | Tests most important Import API part and its nested schemas.
|
@@ -323,3 +372,25 @@ def test_delete_not_found(self, mock_requests):
|
323 | 372 | result = Invoice.destroy(config, uuid='inv_f466e33d-ff2b-4a11-8f85-417eb02157a7').get()
|
324 | 373 |
|
325 | 374 | self.assertEqual(mock_requests.call_count, 1, "expected call")
|
| 375 | + |
| 376 | + @requests_mock.mock() |
| 377 | + def test_retrieve_invoice(self, mock_requests): |
| 378 | + |
| 379 | + mock_requests.register_uri( |
| 380 | + 'GET', |
| 381 | + ("https://api.chartmogul.com/v1/invoices/inv_22910fc6-c931-48e7-ac12-90d2cb5f0059"), |
| 382 | + request_headers={'Authorization': 'Basic dG9rZW46c2VjcmV0'}, |
| 383 | + headers={'Content-Type': 'application/json'}, |
| 384 | + status_code=200, |
| 385 | + text=retrieveInvoiceExample |
| 386 | + ) |
| 387 | + |
| 388 | + config = Config("token", "secret") # is actually checked in mock |
| 389 | + result = Invoice.retrieve(config, uuid='inv_22910fc6-c931-48e7-ac12-90d2cb5f0059').get() |
| 390 | + |
| 391 | + self.assertEqual(mock_requests.call_count, 1, "expected call") |
| 392 | + |
| 393 | + # Struct too complex to do 1:1 comparison |
| 394 | + self.assertTrue(isinstance(result, Invoice)) |
| 395 | + |
| 396 | + self.assertEqual(result.uuid, 'inv_22910fc6-c931-48e7-ac12-90d2cb5f0059') |
0 commit comments