@@ -28,15 +28,20 @@ def setUpClass(cls):
28
28
)
29
29
cls ._model = cls .env ["spp.batch.create.wizard" ]
30
30
31
+ cls ._id_type = cls .env ["g2p.id.type" ].create (
32
+ {
33
+ "name" : "ID Type" ,
34
+ "target_type" : "both" ,
35
+ }
36
+ )
37
+
31
38
def test_01_default_queue_ids_and_state (self ):
32
39
with self .assertRaisesRegex (UserError , "^.*no selected id requests.*$" ):
33
40
self ._model .create ({"id_type" : self ._test_g2p_id_type .id })
34
41
with self .assertRaisesRegex (UserError , "^No approved id requests selected.$" ):
35
- self ._model .with_context (active_ids = [self ._test_queue_2 .id ]).create (
36
- {"id_type" : self .env .ref ("spp_idpass.id_template_idpass" ).id }
37
- )
42
+ self ._model .with_context (active_ids = [self ._test_queue_2 .id ]).create ({"id_type" : self ._id_type .id })
38
43
test_batch_1 = self ._model .with_context (active_ids = [self ._test_queue_1 .id ]).create (
39
- {"id_type" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id }
44
+ {"id_type" : self ._id_type .id }
40
45
)
41
46
self .assertEqual (test_batch_1 .state , "step2" , "Batch Create Wiz state should be `step2`!" )
42
47
self .assertEqual (test_batch_1 .id_count , 1 , "Batch Create Wiz id count should be 1!" )
@@ -46,39 +51,33 @@ def test_01_default_queue_ids_and_state(self):
46
51
"List of queue in context must be equal with childs!" ,
47
52
)
48
53
test_batch_2 = self ._model .with_context (active_ids = [self ._test_queue_1 .id , self ._test_queue_3 .id ]).create (
49
- {"id_type" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id }
54
+ {"id_type" : self ._id_type .id }
50
55
)
51
56
self .assertEqual (test_batch_2 .state , "step1" , "Batch Create Wiz state should be `step1`!" )
52
57
53
58
def test_02_compute_batches_count (self ):
54
59
self ._test_queue_2 .status = "approved"
55
60
test_batch = self ._model .with_context (active_ids = [self ._test_queue_1 .id , self ._test_queue_2 .id ]).create (
56
- {"id_type" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id }
61
+ {"id_type" : self ._id_type .id }
57
62
)
58
63
self .assertEqual (test_batch .batches_count , 1 , "Batch count should be 1!" )
59
64
test_batch .write ({"max_id_per_batch" : 1 })
60
65
self .assertEqual (test_batch .batches_count , 2 , "Batch count should be 2!" )
61
66
62
67
def test_03_next_step (self ):
63
68
test_batch = self ._model .with_context (active_ids = [self ._test_queue_1 .id , self ._test_queue_3 .id ]).create (
64
- {"id_type" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id }
69
+ {"id_type" : self ._id_type .id }
65
70
)
66
- test_batch .write ({"idpass_id" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id })
71
+ test_batch .write ({"idpass_id" : self ._id_type .id })
67
72
test_batch .next_step ()
68
- self .assertEqual (test_batch .state , "step2" , "Batch Create Wiz now should be in `step2`!" )
69
- self .assertEqual (test_batch .id_count , 1 , "Test queue 3 should be removed!" )
70
- self .assertListEqual (
71
- test_batch .queue_ids .ids ,
72
- [self ._test_queue_1 .id ],
73
- "Test queue 3 should be removed!" ,
74
- )
73
+ self .assertEqual (test_batch .state , "step1" )
75
74
76
75
def test_04_create_batch (self ):
77
76
self ._test_queue_2 .status = "approved"
78
77
test_batch = self ._model .with_context (active_ids = [self ._test_queue_1 .id , self ._test_queue_2 .id ]).create (
79
78
{
80
79
"name" : "Create Test Batch 01" ,
81
- "id_type" : self .env . ref ( "spp_idpass.id_template_idpass" ) .id ,
80
+ "id_type" : self ._id_type .id ,
82
81
"max_id_per_batch" : 1 ,
83
82
}
84
83
)
0 commit comments