@@ -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,27 +47,90 @@ 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" : {
57+ "enabled" : True ,
58+ "interval" : 30
59+ },
60+ "invoice_handling_setting" : {
61+ "manual" : {
62+ "create_subscription_when_invoice_is" : "open" ,
63+ "update_subscription_when_invoice_is" : "open" ,
64+ "prevent_subscription_for_invoice_voided" : True ,
65+ "prevent_subscription_for_invoice_refunded" : False ,
66+ "prevent_subscription_for_invoice_written_off" : True
67+ },
68+ "automatic" : {
69+ "create_subscription_when_invoice_is" : "open" ,
70+ "update_subscription_when_invoice_is" : "open" ,
71+ "prevent_subscription_for_invoice_voided" : True ,
72+ "prevent_subscription_for_invoice_refunded" : False ,
73+ "prevent_subscription_for_invoice_written_off" : True
74+ }
75+ }
5176 },
5277 )
5378
5479 config = Config ("token" )
55- ds = DataSource .retrieve (config , uuid = "my_uuid" ).get ()
80+ ds = DataSource .retrieve (
81+ config ,
82+ uuid = "my_uuid" ,
83+ with_processing_status = True ,
84+ with_auto_churn_subscription_setting = True ,
85+ with_invoice_handling_setting = True
86+ ).get ()
5687 expected = DataSource (
5788 ** {
5889 "name" : "test" ,
5990 "uuid" : "my_uuid" ,
6091 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
61- "status" : "never_imported" ,
92+ "status" : "idle" ,
93+ "processing_status" : {
94+ "processed" : 61 ,
95+ "failed" : 3 ,
96+ "pending" : 8
97+ },
98+ "auto_churn_subscription_setting" : {
99+ "enabled" : True ,
100+ "interval" : 30
101+ },
102+ "invoice_handling_setting" : {
103+ "manual" : {
104+ "create_subscription_when_invoice_is" : "open" ,
105+ "update_subscription_when_invoice_is" : "open" ,
106+ "prevent_subscription_for_invoice_voided" : True ,
107+ "prevent_subscription_for_invoice_refunded" : False ,
108+ "prevent_subscription_for_invoice_written_off" : True
109+ },
110+ "automatic" : {
111+ "create_subscription_when_invoice_is" : "open" ,
112+ "update_subscription_when_invoice_is" : "open" ,
113+ "prevent_subscription_for_invoice_voided" : True ,
114+ "prevent_subscription_for_invoice_refunded" : False ,
115+ "prevent_subscription_for_invoice_written_off" : True
116+ }
117+ }
62118 }
63119 )
64120
65121 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
66- self .assertEqual (mock_requests .last_request .qs , {})
122+ self .assertEqual (mock_requests .last_request .qs , {
123+ "with_processing_status" : ["true" ],
124+ "with_auto_churn_subscription_setting" : ["true" ],
125+ "with_invoice_handling_setting" : ["true" ]
126+ })
67127 self .assertEqual (mock_requests .last_request .text , None )
68128 self .assertTrue (isinstance (ds , DataSource ))
69129 self .assertTrue (isinstance (ds .created_at , datetime ))
70130 self .assertEqual (ds .name , "test" )
131+ self .assertEqual (ds .processing_status .processed , 61 )
132+ self .assertEqual (ds .auto_churn_subscription_setting .interval , 30 )
133+ self .assertEqual (ds .invoice_handling_setting ['manual' ]['create_subscription_when_invoice_is' ], "open" )
71134
72135 @requests_mock .mock ()
73136 def test_all (self , mock_requests ):
@@ -81,31 +144,95 @@ def test_all(self, mock_requests):
81144 "name" : "test" ,
82145 "uuid" : "my_uuid" ,
83146 "created_at" : "2016-01-10T15:34:05Z" ,
84- "status" : "never_imported" ,
147+ "status" : "idle" ,
148+ "processing_status" : {
149+ "processed" : 61 ,
150+ "failed" : 3 ,
151+ "pending" : 8
152+ },
153+ "auto_churn_subscription_setting" : {
154+ "enabled" : True ,
155+ "interval" : 30
156+ },
157+ "invoice_handling_setting" : {
158+ "manual" : {
159+ "create_subscription_when_invoice_is" : "open" ,
160+ "update_subscription_when_invoice_is" : "open" ,
161+ "prevent_subscription_for_invoice_voided" : True ,
162+ "prevent_subscription_for_invoice_refunded" : False ,
163+ "prevent_subscription_for_invoice_written_off" : True
164+ },
165+ "automatic" : {
166+ "create_subscription_when_invoice_is" : "open" ,
167+ "update_subscription_when_invoice_is" : "open" ,
168+ "prevent_subscription_for_invoice_voided" : True ,
169+ "prevent_subscription_for_invoice_refunded" : False ,
170+ "prevent_subscription_for_invoice_written_off" : True
171+ }
172+ }
85173 }
86174 ]
87175 },
88176 )
89177
90178 config = Config ("token" )
91- ds = DataSource .all (config ).get ()
179+ ds = DataSource .all (
180+ config ,
181+ with_processing_status = True ,
182+ with_auto_churn_subscription_setting = True ,
183+ with_invoice_handling_setting = True
184+ ).get ()
92185 expected = DataSource ._many (
93186 data_sources = [
94187 DataSource (
95188 ** {
96189 "name" : "test" ,
97190 "uuid" : "my_uuid" ,
98191 "created_at" : datetime (2016 , 1 , 10 , 15 , 34 , 5 ),
99- "status" : "never_imported" ,
192+ "status" : "idle" ,
193+ "processing_status" : {
194+ "processed" : 61 ,
195+ "failed" : 3 ,
196+ "pending" : 8
197+ },
198+ "auto_churn_subscription_setting" : {
199+ "enabled" : True ,
200+ "interval" : 30
201+ },
202+ "invoice_handling_setting" : {
203+ "manual" : {
204+ "create_subscription_when_invoice_is" : "open" ,
205+ "update_subscription_when_invoice_is" : "open" ,
206+ "prevent_subscription_for_invoice_voided" : True ,
207+ "prevent_subscription_for_invoice_refunded" : False ,
208+ "prevent_subscription_for_invoice_written_off" : True
209+ },
210+ "automatic" : {
211+ "create_subscription_when_invoice_is" : "open" ,
212+ "update_subscription_when_invoice_is" : "open" ,
213+ "prevent_subscription_for_invoice_voided" : True ,
214+ "prevent_subscription_for_invoice_refunded" : False ,
215+ "prevent_subscription_for_invoice_written_off" : True
216+ }
217+ }
100218 }
101219 )
102220 ]
103221 )
104222
105223 self .assertEqual (mock_requests .call_count , 1 , "expected call" )
106- self .assertEqual (mock_requests .last_request .qs , {})
224+ self .assertEqual (mock_requests .last_request .qs , {
225+ "with_processing_status" : ["true" ],
226+ "with_auto_churn_subscription_setting" : ["true" ],
227+ "with_invoice_handling_setting" : ["true" ]
228+ })
107229 self .assertEqual (mock_requests .last_request .text , None )
108230 self .assertTrue (isinstance (ds .data_sources [0 ], DataSource ))
231+ self .assertTrue (isinstance (ds .data_sources [0 ].created_at , datetime ))
232+ self .assertEqual (ds .data_sources [0 ].name , "test" )
233+ self .assertEqual (ds .data_sources [0 ].processing_status .processed , 61 )
234+ self .assertEqual (ds .data_sources [0 ].auto_churn_subscription_setting .interval , 30 )
235+ self .assertEqual (ds .data_sources [0 ].invoice_handling_setting ['manual' ]['create_subscription_when_invoice_is' ], "open" )
109236
110237 @requests_mock .mock ()
111238 def test_destroy (self , mock_requests ):
0 commit comments