Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion partner_industry_secondary/tests/test_res_partner_industry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def setUpClass(cls):
cls.partner = cls.env["res.partner"].create({"name": "Test partner"})

def test_00_check_industries(self):
"""Verifies that a partner cannot have the same industry set as both
main and secondary."""
with self.assertRaises(ValidationError):
self.env["res.partner"].create(
{
Expand All @@ -37,21 +39,29 @@ def test_00_check_industries(self):
)

def test_01_check_copy(self):
"""Verifies that when duplicating an industry,
a new name is automatically assigned."""
industry_copy = self.industry_child.copy()
self.assertEqual(industry_copy.name, "Test child 2")

def test_02_check_uniq_name(self):
"""Ensures that two industries with the same name
and parent cannot be created."""
with self.assertRaises(ValidationError):
self.industry_model.create({"name": "Test"})

def test_03_check_recursion(self):
with self.assertRaises(UserError):
"""Checks that a recursive hierarchy among industries is not allowed."""
with self.assertRaisesRegex(UserError, "Recursion Detected."):
self.industry_main.parent_id = self.industry_child.id

def test_04_name(self):
"""Verifies that the 'display_name' field correctly shows the hierarchy."""
self.assertEqual(self.industry_child.display_name, "Test / Test child")

def test_05_check_partner_industries(self):
"""Verifies that a partner cannot have the same industry set as both main
and secondary."""
main = self.industry_main
both = self.industry_main | self.industry_child
with self.assertRaises(ValidationError):
Expand All @@ -60,5 +70,7 @@ def test_05_check_partner_industries(self):
)

def test_06_check_show_partner_industry_for_person(self):
"""Verifies that the system correctly computes whether to show industries
for individuals, based on user group."""
self.partner._compute_show_partner_industry_for_person()
self.assertEqual(self.partner.show_partner_industry_for_person, True)