@@ -48,22 +48,72 @@ def test_retrieve(self, mock_requests):
4848 "uuid" : "my_uuid" ,
4949 "created_at" : "2016-01-10T15:34:05Z" ,
5050 "status" : "never_imported" ,
51+ "processing_status" : {
52+ "processed" : 61
53+ },
54+ "auto_churn_subscription_setting" : True ,
55+ "invoice_handling_setting" : {
56+ "manual" : {
57+ "create_subscription_when_invoice_is" : "open" ,
58+ "update_subscription_when_invoice_is" : "open" ,
59+ "prevent_subscription_for_invoice_voided" : True ,
60+ "prevent_subscription_for_invoice_refunded" : False ,
61+ "prevent_subscription_for_invoice_written_off" : True
62+ },
63+ "automatic" : {
64+ "create_subscription_when_invoice_is" : "open" ,
65+ "update_subscription_when_invoice_is" : "open" ,
66+ "prevent_subscription_for_invoice_voided" : True ,
67+ "prevent_subscription_for_invoice_refunded" : False ,
68+ "prevent_subscription_for_invoice_written_off" : True
69+ }
70+ }
5171 },
5272 )
5373
5474 config = Config ("token" )
55- ds = DataSource .retrieve (config , uuid = "my_uuid" ).get ()
75+ ds = DataSource .retrieve (
76+ config ,
77+ uuid = "my_uuid" ,
78+ with_processing_status = True ,
79+ with_auto_churn_subscription_setting = True ,
80+ with_invoice_handling_setting = True
81+ ).get ()
5682 expected = DataSource (
5783 ** {
5884 "name" : "test" ,
5985 "uuid" : "my_uuid" ,
6086 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
6187 "status" : "never_imported" ,
88+ "processing_status" : {
89+ "processed" : 61
90+ },
91+ "auto_churn_subscription_setting" : True ,
92+ "invoice_handling_setting" : {
93+ "manual" : {
94+ "create_subscription_when_invoice_is" : "open" ,
95+ "update_subscription_when_invoice_is" : "open" ,
96+ "prevent_subscription_for_invoice_voided" : True ,
97+ "prevent_subscription_for_invoice_refunded" : False ,
98+ "prevent_subscription_for_invoice_written_off" : True
99+ },
100+ "automatic" : {
101+ "create_subscription_when_invoice_is" : "open" ,
102+ "update_subscription_when_invoice_is" : "open" ,
103+ "prevent_subscription_for_invoice_voided" : True ,
104+ "prevent_subscription_for_invoice_refunded" : False ,
105+ "prevent_subscription_for_invoice_written_off" : True
106+ }
107+ }
62108 }
63109 )
64110
65111 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
66- self .assertEqual (mock_requests .last_request .qs , {})
112+ self .assertEqual (mock_requests .last_request .qs , {
113+ "with_processing_status" : ["true" ],
114+ "with_auto_churn_subscription_setting" : ["true" ],
115+ "with_invoice_handling_setting" : ["true" ]
116+ })
67117 self .assertEqual (mock_requests .last_request .text , None )
68118 self .assertTrue (isinstance (ds , DataSource ))
69119 self .assertTrue (isinstance (ds .created_at , datetime ))
@@ -82,13 +132,38 @@ def test_all(self, mock_requests):
82132 "uuid" : "my_uuid" ,
83133 "created_at" : "2016-01-10T15:34:05Z" ,
84134 "status" : "never_imported" ,
135+ "processing_status" : {
136+ "processed" : 61
137+ },
138+ "auto_churn_subscription_setting" : True ,
139+ "invoice_handling_setting" : {
140+ "manual" : {
141+ "create_subscription_when_invoice_is" : "open" ,
142+ "update_subscription_when_invoice_is" : "open" ,
143+ "prevent_subscription_for_invoice_voided" : True ,
144+ "prevent_subscription_for_invoice_refunded" : False ,
145+ "prevent_subscription_for_invoice_written_off" : True
146+ },
147+ "automatic" : {
148+ "create_subscription_when_invoice_is" : "open" ,
149+ "update_subscription_when_invoice_is" : "open" ,
150+ "prevent_subscription_for_invoice_voided" : True ,
151+ "prevent_subscription_for_invoice_refunded" : False ,
152+ "prevent_subscription_for_invoice_written_off" : True
153+ }
154+ }
85155 }
86156 ]
87157 },
88158 )
89159
90160 config = Config ("token" )
91- ds = DataSource .all (config ).get ()
161+ ds = DataSource .all (
162+ config ,
163+ with_processing_status = True ,
164+ with_auto_churn_subscription_setting = True ,
165+ with_invoice_handling_setting = True
166+ ).get ()
92167 expected = DataSource ._many (
93168 data_sources = [
94169 DataSource (
@@ -97,13 +172,37 @@ def test_all(self, mock_requests):
97172 "uuid" : "my_uuid" ,
98173 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
99174 "status" : "never_imported" ,
175+ "processing_status" : {
176+ "processed" : 61
177+ },
178+ "auto_churn_subscription_setting" : True ,
179+ "invoice_handling_setting" : {
180+ "manual" : {
181+ "create_subscription_when_invoice_is" : "open" ,
182+ "update_subscription_when_invoice_is" : "open" ,
183+ "prevent_subscription_for_invoice_voided" : True ,
184+ "prevent_subscription_for_invoice_refunded" : False ,
185+ "prevent_subscription_for_invoice_written_off" : True
186+ },
187+ "automatic" : {
188+ "create_subscription_when_invoice_is" : "open" ,
189+ "update_subscription_when_invoice_is" : "open" ,
190+ "prevent_subscription_for_invoice_voided" : True ,
191+ "prevent_subscription_for_invoice_refunded" : False ,
192+ "prevent_subscription_for_invoice_written_off" : True
193+ }
194+ }
100195 }
101196 )
102197 ]
103198 )
104199
105200 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
106- self .assertEqual (mock_requests .last_request .qs , {})
201+ self .assertEqual (mock_requests .last_request .qs , {
202+ "with_processing_status" : ["true" ],
203+ "with_auto_churn_subscription_setting" : ["true" ],
204+ "with_invoice_handling_setting" : ["true" ]
205+ })
107206 self .assertEqual (mock_requests .last_request .text , None )
108207 self .assertTrue (isinstance (ds .data_sources [0 ], DataSource ))
109208
0 commit comments