diff --git a/pms/tests/test_pms_board_service.py b/pms/tests/test_pms_board_service.py index 93bb10c7b..800301c84 100644 --- a/pms/tests/test_pms_board_service.py +++ b/pms/tests/test_pms_board_service.py @@ -22,8 +22,7 @@ class TestBoardService(TestPms): } ) - # external integrity - def test_external_case_01(self): + def test_create_bs_one_company_inconsistent_code(self): """ Creation of board service with the same code as an existing one belonging to the same property should fail. @@ -48,7 +47,6 @@ class TestBoardService(TestPms): "pms_property_ids": [(6, 0, [self.pms_property1.id])], } ) - # ACT & ASSERT with self.assertRaises( ValidationError, msg="The board service has been created and it shouldn't" @@ -62,7 +60,7 @@ class TestBoardService(TestPms): } ) - def test_external_case_02(self): + def test_create_bs_several_companies_inconsistent_code(self): """ Creation of board service with properties and one of its properties has the same code on its board services should fail. @@ -96,7 +94,6 @@ class TestBoardService(TestPms): "pms_property_ids": [(6, 0, [self.pms_property1.id])], } ) - # ACT & ASSERT with self.assertRaises( ValidationError, msg="The board service has been created and it shouldn't" @@ -120,9 +117,11 @@ class TestBoardService(TestPms): } ) - # TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME - def test_single_case_01(self): + def test_search_bs_code_same_company_several_properties(self): """ + Checks the search for a board service by code when the board service + belongs to properties of the same company + PRE: - board service bs1 exists - board_service1 has code c1 - board_service1 has 2 properties pms_property1 and pms_property2 @@ -132,21 +131,26 @@ class TestBoardService(TestPms): POST: - only board_service1 board service found """ # ARRANGE + self.pms_property2 = self.env["pms.property"].create( + { + "name": "Property 2", + "company_id": self.company1.id, + "default_pricelist_id": self.pricelist1.id, + } + ) board_service1 = self.env["pms.board.service"].create( { "name": "Board service 1", "default_code": "c1", "pms_property_ids": [ - (6, 0, [self.pms_property1.id, self.pms_property3.id]) + (6, 0, [self.pms_property1.id, self.pms_property2.id]) ], } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property1.id, "c1" ) - # ASSERT self.assertEqual( board_services.id, @@ -154,12 +158,15 @@ class TestBoardService(TestPms): "Expected board service not found", ) - def test_single_case_02(self): + def test_search_bs_code_several_companies_several_properties_not_found(self): """ + Checks the search for a board service by code when the board service + belongs to properties with different companies + PRE: - board service bs1 exists - board_service1 has code c1 - board_service1 has 2 properties pms_property1 and pms_property3 - - pms_property1 and pms_property2 have different companies + - pms_property1 and pms_property3 have different companies - pms_property1 have company company1 and pms_property3 have company2 ACT: - search board service with code c1 and property pms_property1 - pms_property1 has company company1 @@ -175,16 +182,14 @@ class TestBoardService(TestPms): ], } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property1.id, "c1" ) - # ASSERT self.assertEqual(board_services.id, bs1.id, "Expected board service not found") - def test_single_case_03(self): + def test_search_bs_code_no_result(self): """ Search for a specific board service code and its property. The board service exists but not in the property given. @@ -215,18 +220,16 @@ class TestBoardService(TestPms): ], } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property3.id, "c1" ) - # ASSERT self.assertFalse( board_services, "Board service found but it should not have found any" ) - def test_single_case_04(self): + def test_search_bs_code_present_all_companies_and_properties(self): """ Search for a specific board service and its property. The board service exists without property, then @@ -247,12 +250,10 @@ class TestBoardService(TestPms): "pms_property_ids": False, } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property1.id, "c1" ) - # ASSERT self.assertEqual( board_services.id, @@ -260,18 +261,18 @@ class TestBoardService(TestPms): "Expected board service not found", ) - # TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME - def test_multiple_case_01(self): + def test_search_bs_code_several_companies_several_properties(self): """ Search for a specific board service and its property. There is one board service without properties and - another one with the same code that belongs to 2 properties. + another one with the same code that belongs to 2 properties + (from different companies) The search founds only the board service that match the property given. PRE: - board_service1 exists - board_service1 has code c1 - - board_service1 has 2 properties pms_property1 and pms_property2 + - board_service1 has 2 properties pms_property1 and pms_property3 - pms_property1 and pms_property2 have the same company company1 - board service board_service2 exists - board_service2 has code c1 @@ -309,11 +310,12 @@ class TestBoardService(TestPms): "Expected board service not found", ) - def test_multiple_case_02(self): + def test_search_bs_code_same_companies_several_properties(self): """ Search for a specific board service and its property. There is one board service without properties and - another one with the same code that belongs to 2 properties. + another one with the same code that belongs to 2 properties + (same company). The search founds only the board service that match the property given. @@ -350,12 +352,10 @@ class TestBoardService(TestPms): "pms_property_ids": False, } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property2.id, "c1" ) - # ASSERT self.assertEqual( board_services.id, @@ -363,8 +363,7 @@ class TestBoardService(TestPms): "Expected board service not found", ) - # TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME - def test_multiple_case_03(self): + def test_search_bs_code_no_properties(self): """ Search for a specific board service and its property. There is one board service without properties and @@ -399,61 +398,13 @@ class TestBoardService(TestPms): "pms_property_ids": False, } ) - # ACT board_services = self.env["pms.board.service"].get_unique_by_property_code( self.pms_property3.id, "c1" ) - # ASSERT self.assertEqual( board_services.id, board_service2.id, "Expected board service not found", ) - - def test_multiple_case_04(self): - """ - Search for a specific board service and its property. - There is one board service without properties and - another one with the same code that belongs to 2 properties. - The search founds only the board service that match the - property given. - - PRE: - board_service1 exists - - board_service1 has code c1 - - board_service1 has property pms_property1 - - pms_property1 have the company company1 - - room type board_service2 exists - - board_service2 has code c1 - - board_service2 has no properties - ACT: - search board service with code c1 and property pms_property3 - - pms_property3 have company company2 - POST: - r2 board service found - """ - # ARRANGE - # board_service1 - self.env["pms.board.service"].create( - { - "name": "Board service 1", - "default_code": "c1", - "pms_property_ids": [(6, 0, [self.pms_property1.id])], - } - ) - board_service2 = self.env["pms.board.service"].create( - { - "name": "Board service bs2", - "default_code": "c1", - "pms_property_ids": False, - } - ) - - # ACT - board_services = self.env["pms.board.service"].get_unique_by_property_code( - self.pms_property3.id, "c1" - ) - - # ASSERT - self.assertEqual( - board_services.id, board_service2.id, "Expected room type not found" - )