mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Upodating tests
This commit is contained in:
@@ -44,15 +44,6 @@ class HotelRoomType(models.Model):
|
||||
# total number of rooms in this type
|
||||
total_rooms_count = fields.Integer(compute='_compute_total_rooms')
|
||||
|
||||
@api.multi
|
||||
@api.constrains('room_ids')
|
||||
def _check_capacity(self):
|
||||
for record in self:
|
||||
for room in record.room_ids:
|
||||
if room.room_type_id and room.room_type_id != record.id:
|
||||
raise ValidationError(_("You need change de room type from de room form"))
|
||||
|
||||
|
||||
@api.depends('room_ids')
|
||||
def _compute_total_rooms(self):
|
||||
for record in self:
|
||||
|
||||
@@ -23,3 +23,4 @@
|
||||
#from . import test_reservation
|
||||
#from . import test_folio
|
||||
from . import test_hotel_room_type_model
|
||||
from . import test_hotel_room_model
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import timedelta
|
||||
from odoo import api, fields
|
||||
from odoo import api, fields
|
||||
from odoo.tests import common
|
||||
from odoo.tools import (
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
@@ -81,15 +81,15 @@ class TestHotel(common.SavepointCase):
|
||||
cls._init_mock_hotel()
|
||||
|
||||
# Create Tests Records
|
||||
cls.room_type_0 = cls.env.ref('hotel_room_type_0')
|
||||
cls.room_type_1 = cls.env.ref('hotel_room_type_1')
|
||||
cls.room_type_2 = cls.env.ref('hotel_room_type_2')
|
||||
cls.room_type_3 = cls.env.ref('hotel_room_type_3')
|
||||
cls.room_type_0 = cls.env.ref('hotel.hotel_room_type_0')
|
||||
cls.room_type_1 = cls.env.ref('hotel.hotel_room_type_1')
|
||||
cls.room_type_2 = cls.env.ref('hotel.hotel_room_type_2')
|
||||
cls.room_type_3 = cls.env.ref('hotel.hotel_room_type_3')
|
||||
|
||||
cls.room_0 = cls.env.ref('hotel_room_0')
|
||||
cls.room_1 = cls.env.ref('hotel_room_1')
|
||||
cls.room_2 = cls.env.ref('hotel_room_2')
|
||||
cls.room_3 = cls.env.ref('hotel_room_3')
|
||||
cls.room_4 = cls.env.ref('hotel_room_4')
|
||||
cls.room_5 = cls.env.ref('hotel_room_5')
|
||||
cls.room_6 = cls.env.ref('hotel_room_6')
|
||||
cls.room_0 = cls.env.ref('hotel.hotel_room_0')
|
||||
cls.room_1 = cls.env.ref('hotel.hotel_room_1')
|
||||
cls.room_2 = cls.env.ref('hotel.hotel_room_2')
|
||||
cls.room_3 = cls.env.ref('hotel.hotel_room_3')
|
||||
cls.room_4 = cls.env.ref('hotel.hotel_room_4')
|
||||
cls.room_5 = cls.env.ref('hotel.hotel_room_5')
|
||||
cls.room_6 = cls.env.ref('hotel.hotel_room_6')
|
||||
|
||||
@@ -20,36 +20,15 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import timedelta
|
||||
from .common import TestHotel
|
||||
from odoo.addons.hotel import date_utils
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class TestHotelRoom(TestHotel):
|
||||
|
||||
def test_cancel_folio(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
|
||||
org_reserv_start_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
org_reserv_end_utc_dt = org_reserv_start_utc_dt + timedelta(days=6)
|
||||
folio = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation_a = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
org_reserv_start_utc_dt,
|
||||
org_reserv_end_utc_dt,
|
||||
self.hotel_room_double_200,
|
||||
"Reservation Test #1")
|
||||
reservation_b = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
org_reserv_start_utc_dt,
|
||||
org_reserv_end_utc_dt,
|
||||
self.hotel_room_simple_100,
|
||||
"Reservation Test #2")
|
||||
self.assertEqual(len(folio.room_lines), 2, 'Invalid room lines count')
|
||||
folio.action_cancel()
|
||||
self.assertEqual(folio.state, 'cancel', 'Invalid folio state')
|
||||
for rline in folio.room_lines:
|
||||
self.assertEqual(rline.state, 'cancelled',
|
||||
'Invalid reservation state')
|
||||
def test_check_capacity(self):
|
||||
# TODO Do the test using different users
|
||||
with self.assertRaises(ValidationError):
|
||||
self.room_0.sudo().write({
|
||||
'capacity': 0
|
||||
})
|
||||
|
||||
@@ -21,15 +21,14 @@
|
||||
#
|
||||
##############################################################################
|
||||
from .common import TestHotel
|
||||
from odoo.exceptions import ValidationError
|
||||
from psycopg2 import IntegrityError
|
||||
|
||||
|
||||
class TestHotelRoomType(TestHotel):
|
||||
|
||||
def test_change_room_ids(self):
|
||||
|
||||
# Avoid the unconscious change of room type_id from room_type
|
||||
def test_code_type_unique(self):
|
||||
#TODO: use sudo users hotel
|
||||
with self.assertRaises(ValidationError):
|
||||
cls.room_type_0.sudo().write({
|
||||
'room_ids':(4, cls.room_type_3.id)
|
||||
with self.assertRaises(IntegrityError):
|
||||
self.room_type_0.sudo().write({
|
||||
'code_type': self.room_type_1.code_type
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user