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