[REF] pms: refactor board services tests

This commit is contained in:
miguelpadin
2021-06-10 22:56:14 +02:00
parent 9d2579021c
commit 0300fdac2e
3 changed files with 75 additions and 55 deletions

View File

@@ -19,24 +19,24 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# from . import test_pms_reservation
# from . import test_pms_pricelist
# from . import test_pms_pricelist_priority
# from . import test_pms_checkin_partner
# from . import test_pms_sale_channel
# from . import test_pms_folio
# from . import test_pms_availability_plan_rules
# from . import test_pms_room_type
# from . import test_pms_room_type_class
# from . import test_pms_board_service
from . import test_pms_reservation
from . import test_pms_pricelist
from . import test_pms_pricelist_priority
from . import test_pms_checkin_partner
from . import test_pms_sale_channel
from . import test_pms_folio
from . import test_pms_availability_plan_rules
from . import test_pms_room_type
from . import test_pms_room_type_class
from . import test_pms_board_service
from . import test_pms_wizard_massive_changes
# from . import test_pms_wizard_folio
# from . import test_pms_res_users
# from . import test_pms_amenity
# from . import test_pms_room
# from . import test_pms_board_service_line
# from . import test_pms_board_service_room_type
# from . import test_pms_board_service_room_type_line
# from . import test_pms_folio_invoice
# from . import test_pms_folio_sale_line
# from . import test_pms_wizard_split_join_swap_reservation
from . import test_pms_wizard_folio
from . import test_pms_res_users
from . import test_pms_amenity
from . import test_pms_room
from . import test_pms_board_service_line
from . import test_pms_board_service_room_type
from . import test_pms_board_service_room_type_line
from . import test_pms_folio_invoice
from . import test_pms_folio_sale_line
from . import test_pms_wizard_split_join_swap_reservation

View File

@@ -25,6 +25,9 @@ class TestBoardService(TestPms):
# external integrity
def test_external_case_01(self):
"""
Creation of board service with the same code as an existing one
belonging to the same property should fail.
PRE: - board service bs1 exists
- board_service1 has code c1
- board_service1 has pms_property1
@@ -61,6 +64,9 @@ class TestBoardService(TestPms):
def test_external_case_02(self):
"""
Creation of board service with properties and one of its
properties has the same code on its board services should fail.
PRE: - board service bs1 exists
- board_service1 has code c1
- board_service1 has property pms_property1
@@ -114,6 +120,7 @@ class TestBoardService(TestPms):
}
)
# TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME
def test_single_case_01(self):
"""
PRE: - board service bs1 exists
@@ -179,6 +186,9 @@ class TestBoardService(TestPms):
def test_single_case_03(self):
"""
Search for a specific board service code and its property.
The board service exists but not in the property given.
PRE: - board_service1 exists
- board_service1 has code c1
- board_service1 with 2 properties pms_property1 and pms_property2
@@ -218,6 +228,10 @@ class TestBoardService(TestPms):
def test_single_case_04(self):
"""
Search for a specific board service and its property.
The board service exists without property, then
the search foundS the result.
PRE: - board_service1 exists
- board_service1 has code c1
- board_service1 properties are null
@@ -246,9 +260,15 @@ class TestBoardService(TestPms):
"Expected board service not found",
)
# tests with more than one board service
# TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME
def test_multiple_case_01(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 2 properties pms_property1 and pms_property2
@@ -278,12 +298,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,
@@ -293,6 +311,12 @@ class TestBoardService(TestPms):
def test_multiple_case_02(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
@@ -302,7 +326,7 @@ class TestBoardService(TestPms):
- board_service2 has no properties
ACT: - search board service with code c1 and pms_property2
- pms_property2 have company company1
POST: - only board_service1 board service found
POST: - only board_service2 board service found
"""
# ARRANGE
self.pms_property2 = self.env["pms.property"].create(
@@ -312,7 +336,6 @@ class TestBoardService(TestPms):
"default_pricelist_id": self.pricelist1.id,
}
)
# board_service1
self.env["pms.board.service"].create(
{
"name": "Board service 1",
@@ -340,8 +363,15 @@ class TestBoardService(TestPms):
"Expected board service not found",
)
# TODO: REVIEW. THE NEXT 2 TESTS CHECK THE SAME
def test_multiple_case_03(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 one property.
The search founds only the board service that match the
property given that it's not the same as the 2nd one.
PRE: - board_service1 exists
- board_service1 has code c1
- board_service1 has property pms_property1
@@ -384,6 +414,12 @@ class TestBoardService(TestPms):
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

View File

@@ -3,11 +3,11 @@ import datetime
from freezegun import freeze_time
from odoo import fields
from .common import TestPms
class TestPmsWizardMassiveChanges(TestPms):
def setUp(self):
super().setUp()
self.availability_plan1 = self.env["pms.availability.plan"].create(
@@ -40,9 +40,7 @@ class TestPmsWizardMassiveChanges(TestPms):
self.env["pms.massive.changes.wizard"].create(
{
"massive_changes_on": "availability_plan",
"availability_plan_ids": [
(6, 0, [self.availability_plan1.id])
],
"availability_plan_ids": [(6, 0, [self.availability_plan1.id])],
"start_date": fields.date.today(),
"end_date": fields.date.today() + datetime.timedelta(days=days),
"room_type_ids": [(6, 0, [room_type_double.id])],
@@ -406,9 +404,7 @@ class TestPmsWizardMassiveChanges(TestPms):
"massive_changes_on": "availability_plan",
"availability_plan_ids": [(6, 0, [self.availability_plan1.id])],
"room_type_ids": [(6, 0, [room_type_double.id])],
"pms_property_ids": [
(6, 0, [self.pms_property1.id, pms_property2.id])
],
"pms_property_ids": [(6, 0, [self.pms_property1.id, pms_property2.id])],
"start_date": date_from,
"end_date": date_to,
}
@@ -462,11 +458,7 @@ class TestPmsWizardMassiveChanges(TestPms):
).apply_massive_changes()
# ASSERT
self.assertEqual(
len(
self.pricelist1.item_ids
if self.pricelist1.item_ids
else []
),
len(self.pricelist1.item_ids if self.pricelist1.item_ids else []),
num_exp_items_to_create,
"the number of rules created by the wizard should include all the "
"days between start and finish (both included)",
@@ -647,9 +639,7 @@ class TestPmsWizardMassiveChanges(TestPms):
date_to = fields.date.today()
vals_wizard = {
"massive_changes_on": "pricelist",
"pricelist_ids": [
(6, 0, [self.pricelist1.id, pricelist2.id])
],
"pricelist_ids": [(6, 0, [self.pricelist1.id, pricelist2.id])],
"room_type_ids": [(6, 0, [room_type_double.id])],
"pms_property_ids": [self.pms_property1.id],
"start_date": date_from,
@@ -919,9 +909,7 @@ class TestPmsWizardMassiveChanges(TestPms):
service_breakfast = self.env["product.product"].create(
{"name": "Test Breakfast"}
)
service_dinner = self.env["product.product"].create(
{"name": "Test Dinner"}
)
service_dinner = self.env["product.product"].create({"name": "Test Dinner"})
board_service_single = self.env["pms.board.service.room.type"].create(
{
"pms_room_type_id": room_type_single.id,
@@ -934,19 +922,19 @@ class TestPmsWizardMassiveChanges(TestPms):
"pms_board_service_id": board_service_half_board.id,
}
)
board_service_line_single_1 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
}
)
board_service_line_double_1 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_half_board.id,
}
)
board_service_line_double_2 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_dinner.id,
"pms_board_service_id": board_service_half_board.id,
@@ -1040,9 +1028,7 @@ class TestPmsWizardMassiveChanges(TestPms):
service_breakfast = self.env["product.product"].create(
{"name": "Test Breakfast"}
)
service_dinner = self.env["product.product"].create(
{"name": "Test Dinner"}
)
service_dinner = self.env["product.product"].create({"name": "Test Dinner"})
board_service_single = self.env["pms.board.service.room.type"].create(
{
"pms_room_type_id": room_type_single.id,
@@ -1055,19 +1041,19 @@ class TestPmsWizardMassiveChanges(TestPms):
"pms_board_service_id": board_service_half_board.id,
}
)
board_service_line_single_1 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_only_breakfast.id,
}
)
board_service_line_double_1 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_breakfast.id,
"pms_board_service_id": board_service_half_board.id,
}
)
board_service_line_double_2 = self.env["pms.board.service.line"].create(
self.env["pms.board.service.line"].create(
{
"product_id": service_dinner.id,
"pms_board_service_id": board_service_half_board.id,
@@ -1230,9 +1216,7 @@ class TestPmsWizardMassiveChanges(TestPms):
"pricelist_ids": [(6, 0, [self.pricelist1.id])],
"apply_pricelists_on": "service",
"service": service_spa.id,
"pms_property_ids": [
(6, 0, [self.pms_property1.id, pms_property2.id])
],
"pms_property_ids": [(6, 0, [self.pms_property1.id, pms_property2.id])],
"start_date": date_from,
"end_date": date_to,
"date_types": "sale_dates",