@@ -127,13 +127,12 @@ def test__create_step_d1_02_autoconsum__accept(self):
127
127
d102 .sw_id .history_line [0 ].description .split (":" )[- 1 ].strip (), expected_history_msg
128
128
)
129
129
130
- def test__create_case_m1_01_autoconsum (self ):
130
+ def test__create_case_m1_01_autoconsum_no_auto (self ):
131
131
with Transaction ().start (self .database ) as txn :
132
132
uid = txn .user
133
133
cursor = txn .cursor
134
134
135
135
sw_obj = self .openerp .pool .get ("giscedata.switching" )
136
- m101_obj = self .openerp .pool .get ("giscedata.switching.m1.01" )
137
136
wiz_step_obj = self .openerp .pool .get ("wizard.create.step" )
138
137
139
138
pol_id = self .get_contract_id (txn )
@@ -160,18 +159,12 @@ def test__create_case_m1_01_autoconsum(self):
160
159
wiz_init = {"sw_id" : d1_id }
161
160
wiz_id = wiz_validate_obj .create (cursor , uid , wiz_init )
162
161
wiz = wiz_validate_obj .browse (cursor , uid , wiz_id )
163
- m1_id = wiz ._create_case_m1_01_autoconsum (pol_id )
164
- m1 = sw_obj .browse (cursor , uid , m1_id )
165
-
166
- self .assertEqual (m1 .state , "draft" )
167
- self .assertEqual (len (m1 .step_ids ), 1 )
168
- self .assertEqual (m1 .polissa_ref_id .id , pol_id )
169
-
170
- m101_id = int (m1 .step_ids [- 1 ].pas_id .split ("," )[- 1 ])
171
- m101 = m101_obj .browse (cursor , uid , m101_id )
172
-
173
- self .assertEqual (m101 .sw_id .id , m1 .id )
174
- self .assertEqual (m101 .tipus_autoconsum , u"31" )
162
+ with self .assertRaises (except_osv ) as error :
163
+ wiz ._create_case_m1_01_autoconsum (pol_id )
164
+ self .assertIn (
165
+ u"No s'ha pogut crear el cas M1 per la pòlissa 1 al no haver-hi un autoconsum" ,
166
+ error .exception .message ,
167
+ )
175
168
176
169
def test__create_case_m1_01_autoconsum__exception (self ):
177
170
with Transaction ().start (self .database ) as txn :
@@ -269,11 +262,7 @@ def test__validate_d101__accept_m101_exception(self, mock_create_case_m1_01):
269
262
d102_id = int (step_info .pas_id .split ("," )[- 1 ])
270
263
d102 = d102_obj .browse (cursor , uid , d102_id )
271
264
272
- self .assertEqual (step_info .step_id .name , "02" )
273
- self .assertEqual (d102 .sw_id .id , d1_id )
274
- self .assertFalse (d102 .rebuig )
275
265
self .assertTrue (d1 .validacio_pendent )
276
- self .assertTrue (d102 .validacio_pendent )
277
266
278
267
historize_msg = (
279
268
"Hi ha hagut un error al generar el cas M1 després d'acceptar "
@@ -290,8 +279,8 @@ def test__create_step_d1_02_motiu_06__accept_done(self):
290
279
291
280
sw_obj = self .openerp .pool .get ("giscedata.switching" )
292
281
d101_obj = self .openerp .pool .get ("giscedata.switching.d1.01" )
293
- d102_obj = self .openerp .pool .get ("giscedata.switching.d1.02" )
294
282
wiz_validate_obj = self .openerp .pool .get ("wizard.validate.d101" )
283
+ gen_obj = self .openerp .pool .get ("giscedata.autoconsum.generador" )
295
284
296
285
d1_id = self .create_d1_case_at_step_01 (txn )
297
286
@@ -300,21 +289,34 @@ def test__create_step_d1_02_motiu_06__accept_done(self):
300
289
id_pas = int (pas_id .split ("," )[1 ])
301
290
d101_obj .write (cursor , uid , [id_pas ], {"motiu_canvi" : "06" })
302
291
303
- wiz_init = { "sw_id" : d1_id }
304
- wiz_id = wiz_validate_obj . create ( cursor , uid , wiz_init )
305
- wiz = wiz_validate_obj . browse ( cursor , uid , wiz_id )
292
+ imd_obj = self . openerp . pool . get ( "ir.model.data" )
293
+ auto_id = imd_obj . get_object_reference (
294
+ cursor , uid , "giscedata_cups" , "autoconsum_collectiu_xarxa_interior" )[ 1 ]
306
295
307
- wiz .validate_d101_autoconsum ()
296
+ gen_id = imd_obj .get_object_reference (
297
+ cursor , uid , "giscedata_cups" , "generador_autoconsum_collectiu_xarxa_interior" )[1 ]
308
298
309
- d102_id = wiz . read ([ "generated_d102" ])[ 0 ][ "generated_d102" ]
299
+ gen_obj . write ( cursor , uid , gen_id , { "partner_id" : 3 })
310
300
311
- sw_id = d102_obj .read (cursor , uid , d102_id , ["sw_id" ])["sw_id" ][0 ]
312
- sw_obj .write (cursor , uid , sw_id , {"state" : "done" })
301
+ pol_obj = self .openerp .pool .get ("giscedata.polissa" )
313
302
314
- d102 = d102_obj .browse (cursor , uid , d102_id )
303
+ tipus_subseccio = pol_obj .read (
304
+ cursor , uid , sw .cups_polissa_id .id , ["tipus_subseccio" ])["tipus_subseccio" ]
305
+ self .assertEqual (tipus_subseccio , '00' )
315
306
316
- self .assertEqual (d102 .sw_id .id , d1_id )
317
- self .assertEqual (d102 .sw_id .state , "done" )
307
+ wiz_init = {"sw_id" : d1_id , 'autoconsum_id' : auto_id }
308
+ wiz_id = wiz_validate_obj .create (cursor , uid , wiz_init )
309
+ wiz = wiz_validate_obj .browse (cursor , uid , wiz_id )
310
+
311
+ d102 , m101 = wiz .validate_d101_autoconsum ()
312
+
313
+ tipus_subseccio = pol_obj .read (
314
+ cursor , uid , sw .cups_polissa_id .id , ["tipus_subseccio" ])["tipus_subseccio" ]
315
+ self .assertEqual (tipus_subseccio , '00' )
316
+
317
+ # m1 esborrany
318
+ self .assertNotEqual (m101 , False )
319
+ self .assertEqual (d102 , False )
318
320
319
321
@unittest .skip ("Waiting for ATR3.0" )
320
322
def test__create_case_m1_01_motiu_06__S_R (self ):
0 commit comments