-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_spp_program_create_wizard_compliance.py
More file actions
53 lines (47 loc) · 2 KB
/
test_spp_program_create_wizard_compliance.py
File metadata and controls
53 lines (47 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from odoo.exceptions import ValidationError
from . import common_compliance as common
class TestSppProgramCreateWiz(common.Common):
@classmethod
def setUpClass(cls):
super().setUpClass()
def test_01_create_program_without_compliance_manager(self):
wizard = self.program_create_wizard({})
wizard._check_compliance_manager_info()
action = wizard.create_program()
program = self.env["spp.program"].browse(action["params"]["program_id"])
self.assertFalse(
bool(program.compliance_manager_ids),
"Should not create compliance manager for new program!",
)
def test_02_create_program_errors(self):
wizard = self.program_create_wizard(
{
"enable_compliance_verification": True,
"compliance_type": None,
}
)
error = "^Not enough information for creating compliance manager!$"
with self.assertRaisesRegex(ValidationError, error):
wizard.create_program()
def test_03_create_program_default_compliance_manager(self):
wizard = self.program_create_wizard(
{
"enable_compliance_verification": True,
"compliance_type": "spp.compliance.manager.default",
"compliance_cel_expression": "r.id > 2",
}
)
action = wizard.create_program()
program = self.env["spp.program"].browse(action["params"]["program_id"])
self.assertTrue(
bool(program.compliance_manager_ids),
"Should create compliance manager for new program!",
)
manager = program.compliance_manager_ids[0].manager_ref_id
self.assertEqual(
manager._name,
"spp.compliance.manager.default",
"Manager should be correct!",
)
self.assertEqual(manager.compliance_cel_expression, "r.id > 2", "Manager should be correct!")
self.assertEqual(manager.program_id, program, "Manager should be correct!")