mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP]pms: change checkin name field arriva-departure
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
import logging
|
||||
|
||||
from freezegun import freeze_time
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from .common import TestHotel
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@freeze_time("2012-01-14")
|
||||
class TestPmsCheckinPartner(TestHotel):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestHotel, cls).setUpClass()
|
||||
|
||||
def test_create_checkin_partner(self):
|
||||
|
||||
# ARRANGE
|
||||
host1 = self.env["res.partner"].create(
|
||||
def arrange_single_checkin(cls):
|
||||
# Arrange for one checkin on one reservation
|
||||
cls.host1 = cls.env["res.partner"].create(
|
||||
{
|
||||
"name": "Miguel",
|
||||
"phone": "654667733",
|
||||
@@ -22,27 +25,124 @@ class TestPmsCheckinPartner(TestHotel):
|
||||
reservation_vals = {
|
||||
"checkin": "2012-01-14",
|
||||
"checkout": "2012-01-17",
|
||||
"room_type_id": self.env.ref("pms.pms_room_type_3").id,
|
||||
"partner_id": host1.id,
|
||||
"pms_property_id": self.env.ref("pms.main_pms_property").id,
|
||||
"room_type_id": cls.env.ref("pms.pms_room_type_3").id,
|
||||
"partner_id": cls.host1.id,
|
||||
"pms_property_id": cls.env.ref("pms.main_pms_property").id,
|
||||
}
|
||||
demo_user = self.env.ref("base.user_demo")
|
||||
|
||||
# ACT
|
||||
reservation_1 = (
|
||||
self.env["pms.reservation"].with_user(demo_user).create(reservation_vals)
|
||||
demo_user = cls.env.ref("base.user_demo")
|
||||
cls.reservation_1 = (
|
||||
cls.env["pms.reservation"].with_user(demo_user).create(reservation_vals)
|
||||
)
|
||||
checkin1 = self.env["pms.checkin.partner"].create(
|
||||
cls.checkin1 = cls.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": host1.id,
|
||||
"reservation_id": reservation_1.id,
|
||||
"partner_id": cls.host1.id,
|
||||
"reservation_id": cls.reservation_1.id,
|
||||
}
|
||||
)
|
||||
checkin1.onboard()
|
||||
|
||||
def test_onboard_checkin(self):
|
||||
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
|
||||
# ACT
|
||||
self.checkin1.action_on_board()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
checkin1.state,
|
||||
self.checkin1.state,
|
||||
"onboard",
|
||||
"the checkin was not successful",
|
||||
"the partner checkin was not successful",
|
||||
)
|
||||
|
||||
def test_onboard_reservation(self):
|
||||
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
|
||||
# ACT
|
||||
self.checkin1.action_on_board()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
self.reservation_1.state,
|
||||
"onboard",
|
||||
"the reservation checkin was not successful",
|
||||
)
|
||||
|
||||
def test_premature_checkin(self):
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
self.reservation_1.write(
|
||||
{
|
||||
"checkin": "2012-01-15",
|
||||
}
|
||||
)
|
||||
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
self.checkin1.action_on_board()
|
||||
|
||||
def test_late_checkin(self):
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
self.reservation_1.write(
|
||||
{
|
||||
"checkin": "2012-01-13",
|
||||
}
|
||||
)
|
||||
|
||||
# ACT
|
||||
self.checkin1.action_on_board()
|
||||
|
||||
# ASSERT
|
||||
self.assertEqual(
|
||||
self.checkin1.arrival,
|
||||
fields.datetime.now(),
|
||||
"the late checkin has problems",
|
||||
)
|
||||
|
||||
def test_too_many_people_checkin(self):
|
||||
# ARRANGE
|
||||
self.arrange_single_checkin()
|
||||
host2 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Carlos",
|
||||
"phone": "654667733",
|
||||
"email": "carlos@example.com",
|
||||
}
|
||||
)
|
||||
host3 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Enmanuel",
|
||||
"phone": "654667733",
|
||||
"email": "enmanuel@example.com",
|
||||
}
|
||||
)
|
||||
host4 = self.env["res.partner"].create(
|
||||
{
|
||||
"name": "Enrique",
|
||||
"phone": "654667733",
|
||||
"email": "enrique@example.com",
|
||||
}
|
||||
)
|
||||
self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": host2.id,
|
||||
"reservation_id": self.reservation_1.id,
|
||||
}
|
||||
)
|
||||
self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": host3.id,
|
||||
"reservation_id": self.reservation_1.id,
|
||||
}
|
||||
)
|
||||
# ACT & ASSERT
|
||||
with self.assertRaises(ValidationError), self.cr.savepoint():
|
||||
self.env["pms.checkin.partner"].create(
|
||||
{
|
||||
"partner_id": host4.id,
|
||||
"reservation_id": self.reservation_1.id,
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user