@@ -447,3 +447,55 @@ def test_retrieve_invoice(self, mock_requests):
447447 self .assertTrue (isinstance (result , Invoice ))
448448
449449 self .assertEqual (result .uuid , "inv_22910fc6-c931-48e7-ac12-90d2cb5f0059" )
450+
451+ @requests_mock .mock ()
452+ def test_retrieve_invoice_with_validation_type (self , mock_requests ):
453+ mock_requests .register_uri (
454+ "GET" ,
455+ ("https://api.chartmogul.com/v1/invoices/inv_22910fc6-c931-48e7-ac12-90d2cb5f0059"
456+ "?validation_type=all" ),
457+ request_headers = {"Authorization" : "Basic dG9rZW46" },
458+ headers = {"Content-Type" : "application/json" },
459+ status_code = 200 ,
460+ json = retrieveInvoiceExample ,
461+ )
462+
463+ config = Config ("token" ) # is actually checked in mock
464+ result = Invoice .retrieve (
465+ config ,
466+ uuid = "inv_22910fc6-c931-48e7-ac12-90d2cb5f0059" ,
467+ validation_type = "all"
468+ ).get ()
469+
470+ self .assertEqual (mock_requests .call_count , 1 , "expected call" )
471+ vt = []
472+ vt .append ("all" )
473+ self .assertEqual (mock_requests .last_request .qs , {"validation_type" : vt })
474+
475+ # Struct too complex to do 1:1 comparison
476+ self .assertTrue (isinstance (result , Invoice ))
477+
478+ self .assertEqual (result .uuid , "inv_22910fc6-c931-48e7-ac12-90d2cb5f0059" )
479+
480+ @requests_mock .mock ()
481+ def test_all_invoices_with_validation_type (self , mock_requests ):
482+ mock_requests .register_uri (
483+ "GET" ,
484+ "https://api.chartmogul.com/v1/invoices?validation_type=all" ,
485+ request_headers = {"Authorization" : "Basic dG9rZW46" },
486+ headers = {"Content-Type" : "application/json" },
487+ status_code = 200 ,
488+ json = invoiceListExample ,
489+ )
490+
491+ config = Config ("token" ) # is actually checked in mock
492+ result = Invoice .all (config , validation_type = "all" ).get ()
493+
494+ self .assertEqual (mock_requests .call_count , 1 , "expected call" )
495+ vt = []
496+ vt .append ("all" )
497+ self .assertEqual (mock_requests .last_request .qs , {"validation_type" : vt })
498+
499+ # Struct too complex to do 1:1 comparison
500+ self .assertTrue (isinstance (result , Invoice ._many ))
501+ self .assertEqual (len (result .invoices ), 1 )
0 commit comments