@@ -22,7 +22,7 @@ def test_create(self, mock_requests):
2222 "name" : "test" ,
2323 "uuid" : "my_uuid" ,
2424 "created_at" : "2016-01-10T15:34:05.144Z" ,
25- "status" : "never_imported " ,
25+ "status" : "idle " ,
2626 },
2727 )
2828
@@ -47,23 +47,77 @@ def test_retrieve(self, mock_requests):
4747 "name" : "test" ,
4848 "uuid" : "my_uuid" ,
4949 "created_at" : "2016-01-10T15:34:05Z" ,
50- "status" : "never_imported" ,
50+ "status" : "idle" ,
51+ "processing_status" : {
52+ "processed" : 61 ,
53+ "failed" : 3 ,
54+ "pending" : 8
55+ },
56+ "auto_churn_subscription_setting" : True ,
57+ "invoice_handling_setting" : {
58+ "manual" : {
59+ "create_subscription_when_invoice_is" : "open" ,
60+ "update_subscription_when_invoice_is" : "open" ,
61+ "prevent_subscription_for_invoice_voided" : True ,
62+ "prevent_subscription_for_invoice_refunded" : False ,
63+ "prevent_subscription_for_invoice_written_off" : True
64+ },
65+ "automatic" : {
66+ "create_subscription_when_invoice_is" : "open" ,
67+ "update_subscription_when_invoice_is" : "open" ,
68+ "prevent_subscription_for_invoice_voided" : True ,
69+ "prevent_subscription_for_invoice_refunded" : False ,
70+ "prevent_subscription_for_invoice_written_off" : True
71+ }
72+ }
5173 },
5274 )
5375
5476 config = Config ("token" )
55- ds = DataSource .retrieve (config , uuid = "my_uuid" ).get ()
77+ ds = DataSource .retrieve (
78+ config ,
79+ uuid = "my_uuid" ,
80+ with_processing_status = True ,
81+ with_auto_churn_subscription_setting = True ,
82+ with_invoice_handling_setting = True
83+ ).get ()
5684 expected = DataSource (
5785 ** {
5886 "name" : "test" ,
5987 "uuid" : "my_uuid" ,
6088 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
61- "status" : "never_imported" ,
89+ "status" : "idle" ,
90+ "processing_status" : {
91+ "processed" : 61 ,
92+ "failed" : 3 ,
93+ "pending" : 8
94+ },
95+ "auto_churn_subscription_setting" : True ,
96+ "invoice_handling_setting" : {
97+ "manual" : {
98+ "create_subscription_when_invoice_is" : "open" ,
99+ "update_subscription_when_invoice_is" : "open" ,
100+ "prevent_subscription_for_invoice_voided" : True ,
101+ "prevent_subscription_for_invoice_refunded" : False ,
102+ "prevent_subscription_for_invoice_written_off" : True
103+ },
104+ "automatic" : {
105+ "create_subscription_when_invoice_is" : "open" ,
106+ "update_subscription_when_invoice_is" : "open" ,
107+ "prevent_subscription_for_invoice_voided" : True ,
108+ "prevent_subscription_for_invoice_refunded" : False ,
109+ "prevent_subscription_for_invoice_written_off" : True
110+ }
111+ }
62112 }
63113 )
64114
65115 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
66- self .assertEqual (mock_requests .last_request .qs , {})
116+ self .assertEqual (mock_requests .last_request .qs , {
117+ "with_processing_status" : ["true" ],
118+ "with_auto_churn_subscription_setting" : ["true" ],
119+ "with_invoice_handling_setting" : ["true" ]
120+ })
67121 self .assertEqual (mock_requests .last_request .text , None )
68122 self .assertTrue (isinstance (ds , DataSource ))
69123 self .assertTrue (isinstance (ds .created_at , datetime ))
@@ -81,29 +135,82 @@ def test_all(self, mock_requests):
81135 "name" : "test" ,
82136 "uuid" : "my_uuid" ,
83137 "created_at" : "2016-01-10T15:34:05Z" ,
84- "status" : "never_imported" ,
138+ "status" : "idle" ,
139+ "processing_status" : {
140+ "processed" : 61 ,
141+ "failed" : 3 ,
142+ "pending" : 8
143+ },
144+ "auto_churn_subscription_setting" : True ,
145+ "invoice_handling_setting" : {
146+ "manual" : {
147+ "create_subscription_when_invoice_is" : "open" ,
148+ "update_subscription_when_invoice_is" : "open" ,
149+ "prevent_subscription_for_invoice_voided" : True ,
150+ "prevent_subscription_for_invoice_refunded" : False ,
151+ "prevent_subscription_for_invoice_written_off" : True
152+ },
153+ "automatic" : {
154+ "create_subscription_when_invoice_is" : "open" ,
155+ "update_subscription_when_invoice_is" : "open" ,
156+ "prevent_subscription_for_invoice_voided" : True ,
157+ "prevent_subscription_for_invoice_refunded" : False ,
158+ "prevent_subscription_for_invoice_written_off" : True
159+ }
160+ }
85161 }
86162 ]
87163 },
88164 )
89165
90166 config = Config ("token" )
91- ds = DataSource .all (config ).get ()
167+ ds = DataSource .all (
168+ config ,
169+ with_processing_status = True ,
170+ with_auto_churn_subscription_setting = True ,
171+ with_invoice_handling_setting = True
172+ ).get ()
92173 expected = DataSource ._many (
93174 data_sources = [
94175 DataSource (
95176 ** {
96177 "name" : "test" ,
97178 "uuid" : "my_uuid" ,
98179 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
99- "status" : "never_imported" ,
180+ "status" : "idle" ,
181+ "processing_status" : {
182+ "processed" : 61 ,
183+ "failed" : 3 ,
184+ "pending" : 8
185+ },
186+ "auto_churn_subscription_setting" : True ,
187+ "invoice_handling_setting" : {
188+ "manual" : {
189+ "create_subscription_when_invoice_is" : "open" ,
190+ "update_subscription_when_invoice_is" : "open" ,
191+ "prevent_subscription_for_invoice_voided" : True ,
192+ "prevent_subscription_for_invoice_refunded" : False ,
193+ "prevent_subscription_for_invoice_written_off" : True
194+ },
195+ "automatic" : {
196+ "create_subscription_when_invoice_is" : "open" ,
197+ "update_subscription_when_invoice_is" : "open" ,
198+ "prevent_subscription_for_invoice_voided" : True ,
199+ "prevent_subscription_for_invoice_refunded" : False ,
200+ "prevent_subscription_for_invoice_written_off" : True
201+ }
202+ }
100203 }
101204 )
102205 ]
103206 )
104207
105208 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
106- self .assertEqual (mock_requests .last_request .qs , {})
209+ self .assertEqual (mock_requests .last_request .qs , {
210+ "with_processing_status" : ["true" ],
211+ "with_auto_churn_subscription_setting" : ["true" ],
212+ "with_invoice_handling_setting" : ["true" ]
213+ })
107214 self .assertEqual (mock_requests .last_request .text , None )
108215 self .assertTrue (isinstance (ds .data_sources [0 ], DataSource ))
109216
0 commit comments