Merge PR #37 into 14.0

Signed-off-by DarioLodeiros
This commit is contained in:
OCA-git-bot
2021-07-13 11:53:56 +00:00
2 changed files with 441 additions and 474 deletions

View File

@@ -25,16 +25,12 @@ class TestRoomTypeClass(TestPms):
# external integrity # external integrity
def test_external_case_01(self): def test_external_case_01(self):
""" """
PRE: - room type class cl1 exists Check that a room type class cannot be created with an existing default_code
- room_type_class1 has code c1 in the same property.
- room_type_class1 has pms_property1 ----------
- pms_property1 has company company1 A room type class is created with the default_code = 'c1' in property pms_property1.
ACT: - create a new room_type_class2 class Then try to create another room type class in the same property with the same code,
- room_type_class2 has code c1 but this should throw a ValidationError.
- room_type_class2 has pms_property1
- pms_property1 has company company1
POST: - Integrity error: the room type already exists
- room_type_class2 not created
""" """
# ARRANGE # ARRANGE
# room_type_class1 # room_type_class1
@@ -61,18 +57,13 @@ class TestRoomTypeClass(TestPms):
def test_external_case_02(self): def test_external_case_02(self):
""" """
PRE: - room type class cl1 exists Check that a room type class cannot be created with an existing default_code
- room_type_class1 has code c1 in the same property.
- room_type_class1 has property pms_property1 ----------
- pms_property1 has company company1 A room type class is created with the default_code = 'c1' in property pms_property1.
ACT: - create a new room_type_class2 class Then try to create another room type class with the same code in 3 properties and one
- room_type_class2 has code c1 of them is the same property in which the other room type class was
- room_type_class2 has property pms_property1, pms_property2, created(pms_property1), but this should throw a ValidationError.
pms_property3
- pms_property1, pms_property2 has company company1
- pms_property3 has company company2
POST: - Integrity error: the room type class already exists
- room_type_class2 not created
""" """
# ARRANGE # ARRANGE
self.pms_property2 = self.env["pms.property"].create( self.pms_property2 = self.env["pms.property"].create(
@@ -116,13 +107,14 @@ class TestRoomTypeClass(TestPms):
def test_single_case_01(self): def test_single_case_01(self):
""" """
PRE: - room type class cl1 exists Check that the room type class was created correctly and that
- room_type_class1 has code c1 it is in the property in which it was searched through its default code.
- room_type_class1 has 2 properties pms_property1 and pms_property2 -----------
- pms_property_1 and pms_property2 have the same company company1 Create a room type class with default code as 'c1' for properties 1 and 3
ACT: - search room type class with code c1 and pms_property1 (different companies), save the value returned by the get_unique_by_property_code()
- pms_property1 has company company1 method, passing property1 and default_code 'c1' as parameters. It is checked
POST: - only room_type_class1 room type class found that the id of the room type class created and the id of the record returned by the
method match.
""" """
# ARRANGE # ARRANGE
room_type_class1 = self.env["pms.room.type.class"].create( room_type_class1 = self.env["pms.room.type.class"].create(
@@ -149,22 +141,29 @@ class TestRoomTypeClass(TestPms):
def test_single_case_02(self): def test_single_case_02(self):
""" """
PRE: - room type class cl1 exists Check that the room type class was created correctly and that
- room_type_class1 has code c1 it is in the property in which it was searched through its default code.
- room_type_class1 has 2 properties pms_property1 and pms_property3 -----------
- pms_property1 and pms_property2 have different companies Create a room type class with default code as 'c1' for properties 1 and 3
- pms_property1 have company company1 and pms_property3 have company2 (same company), save the value returned by the get_unique_by_property_code()
ACT: - search room type class with code c1 and property pms_property1 method, passing property1 and default_code 'c1' as parameters. It is checked
- pms_property1 has company company1 that the id of the room type class created and the id of the record returned by the
POST: - only room_type_class1 room type found method match.
""" """
# ARRANGE # ARRANGE
self.pms_property2 = self.env["pms.property"].create(
{
"name": "Property 2",
"company_id": self.company1.id,
"default_pricelist_id": self.pricelist1.id,
}
)
cl1 = self.env["pms.room.type.class"].create( cl1 = self.env["pms.room.type.class"].create(
{ {
"name": "Room type class 1", "name": "Room type class 1",
"default_code": "c1", "default_code": "c1",
"pms_property_ids": [ "pms_property_ids": [
(6, 0, [self.pms_property1.id, self.pms_property3.id]) (6, 0, [self.pms_property1.id, self.pms_property2.id])
], ],
} }
) )
@@ -181,13 +180,14 @@ class TestRoomTypeClass(TestPms):
def test_single_case_03(self): def test_single_case_03(self):
""" """
PRE: - room_type_class1 exists Check that a room type class created for a property is not
- room_type_class1 has code c1 found in another property with a different company.
- room_type_class1 with 2 properties pms_property1 and pms_property2 -----------
- pms_property1 and pms_property2 have same company company1 A room type class is created with default_code 'c1' for properties
ACT: - search room type class with code c1 and property pms_property3 1 and 2. It is searched through get_unique_by_property_code()
- pms_property3 have company company2 passing it as parameters 'c1' and property 3 (from a different
POST: - no room type found company than 1 and 2). It is verified that that room type class
does not exist in that property.
""" """
# ARRANGE # ARRANGE
self.pms_property2 = self.env["pms.property"].create( self.pms_property2 = self.env["pms.property"].create(
@@ -220,12 +220,15 @@ class TestRoomTypeClass(TestPms):
def test_single_case_04(self): def test_single_case_04(self):
""" """
PRE: - room_type_class1 exists Check that a room type class with properties = False
- room_type_class1 has code c1 (all properties) is found by searching for it in one
- room_type_class1 properties are null of the properties.
ACT: - search room type class with code c1 and property pms_property1 --------------
- pms_property1 have company company1 A room type is created with default code = 'c1' and with
POST: - only room_type_class1 room type class found pms_property_ids = False. The room_type_class with
code 'c1' in property 1 is searched through the
get_unique_by_property_code() method and it is verified
that the returned value is correct.
""" """
# ARRANGE # ARRANGE
room_type_class1 = self.env["pms.room.type.class"].create( room_type_class1 = self.env["pms.room.type.class"].create(
@@ -251,16 +254,14 @@ class TestRoomTypeClass(TestPms):
# tests with more than one room type class # tests with more than one room type class
def test_multiple_case_01(self): def test_multiple_case_01(self):
""" """
PRE: - room_type_class1 exists Check that a room type class can be created with the same
- room_type_class1 has code c1 code as another when one of them has pms_property_ids = False
- room_type_class1 has 2 properties pms_property1 and pms_property2 ------------
- pms_property1 and pms_property2 have the same company company1 A room type class is created with code 'c1' for properties 1 and 3.
- room type class room_type_class2 exists Another room type class is created with code 'c1' and the properties
- room_type_class2 has code c1 set to False. The room_type with code 'c1' in property 1 is
- room_type_class2 has no properties searched through the get_unique_by_property_code() method and it is
ACT: - search room type class with code c1 and property pms_property1 verified that the returned value is correct.
- pms_property1 have company company1
POST: - only room_type_class1 room type class found
""" """
# ARRANGE # ARRANGE
room_type_class1 = self.env["pms.room.type.class"].create( room_type_class1 = self.env["pms.room.type.class"].create(
@@ -295,16 +296,14 @@ class TestRoomTypeClass(TestPms):
def test_multiple_case_02(self): def test_multiple_case_02(self):
""" """
PRE: - room_type_class1 exists Check that a room type class can be created with the same
- room_type_class1 has code c1 code as another when one of them has pms_property_ids = False
- room_type_class1 has property pms_property1 ----------
- pms_property1 have the company company1 A room type class is created with code 'c1' for property 1(company1).
- room type class room_type_class2 exists Another room type class is created with code 'c1' and the
- room_type_class2 has code c1 properties set to False. Then the room_type with code 'c1'
- room_type_class2 has no properties in property 2(company1) is searched through the
ACT: - search room type class with code c1 and pms_property2 get_unique_by_property_code() method and the result is checked.
- pms_property2 have company company1
POST: - only room_type_class1 room type class found
""" """
# ARRANGE # ARRANGE
self.pms_property2 = self.env["pms.property"].create( self.pms_property2 = self.env["pms.property"].create(
@@ -344,16 +343,14 @@ class TestRoomTypeClass(TestPms):
def test_multiple_case_03(self): def test_multiple_case_03(self):
""" """
PRE: - room_type_class1 exists Check that a room type class can be created with the same
- room_type_class1 has code c1 code as another when one of them has pms_property_ids = False
- room_type_class1 has property pms_property1 ----------
- pms_property1 have the company company1 A room type class is created with code 'c1' for property 1(company1).
- room type class room_type_class2 exists Another room type class is created with code 'c1' and the
- room_type_class2 has code c1 properties set to False. Then the room_type with code 'c1'
- room_type_class2 has no properties in property 3(company2) is searched through the
ACT: - search room type class with code c1 and property pms_property3 get_unique_by_property_code() method and the result is checked.
- pms_property3 have company company2
POST: - only room_type_class2 room type class found
""" """
# ARRANGE # ARRANGE
# room_type_class1 # room_type_class1
@@ -383,43 +380,3 @@ class TestRoomTypeClass(TestPms):
room_type_class2.id, room_type_class2.id,
"Expected room type class not found", "Expected room type class not found",
) )
def test_multiple_case_04(self):
"""
PRE: - room_type_class1 exists
- room_type_class1 has code c1
- room_type_class1 has property pms_property1
- pms_property1 have the company company1
- room type room_type_class2 exists
- room_type_class2 has code c1
- room_type_class2 has no properties
ACT: - search room type class with code c1 and property pms_property3
- pms_property3 have company company2
POST: - r2 room type class found
"""
# ARRANGE
# room_type_class1
self.env["pms.room.type.class"].create(
{
"name": "Room type class 1",
"default_code": "c1",
"pms_property_ids": [(6, 0, [self.pms_property1.id])],
}
)
room_type_class2 = self.env["pms.room.type.class"].create(
{
"name": "Room type class cl2",
"default_code": "c1",
"pms_property_ids": False,
}
)
# ACT
room_type_classes = self.env["pms.room.type.class"].get_unique_by_property_code(
self.pms_property3.id, "c1"
)
# ASSERT
self.assertEqual(
room_type_classes.id, room_type_class2.id, "Expected room type not found"
)

File diff suppressed because it is too large Load Diff