mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Add sketch unittests for addons hotel_channel_connector_wubook
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import test_channel_hotel_room_type_adapter_model
|
||||||
@@ -22,13 +22,12 @@
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odoo import api
|
from odoo import api
|
||||||
from odoo.addons.hotel import date_utils
|
|
||||||
from odoo.addons.hotel.tests.common import TestHotel
|
from odoo.addons.hotel.tests.common import TestHotel
|
||||||
from odoo.addons.hotel_wubook_proto.wubook import (
|
# from odoo.addons.hotel_wubook_proto.wubook import (
|
||||||
DEFAULT_WUBOOK_DATE_FORMAT,
|
# DEFAULT_WUBOOK_DATE_FORMAT,
|
||||||
DEFAULT_WUBOOK_TIME_FORMAT,
|
# DEFAULT_WUBOOK_TIME_FORMAT,
|
||||||
WUBOOK_STATUS_CONFIRMED,
|
# WUBOOK_STATUS_CONFIRMED,
|
||||||
WUBOOK_STATUS_CANCELLED)
|
# WUBOOK_STATUS_CANCELLED)
|
||||||
from random import randint
|
from random import randint
|
||||||
import logging
|
import logging
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
@@ -38,7 +37,7 @@ class TestHotelWubook(TestHotel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _init_mock_hotel(cls):
|
def _init_mock_hotel(cls):
|
||||||
super(TestHotelWubook, cls)._init_mock_hotel()
|
super()._init_mock_hotel()
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def wubook_ommit(self, *args, **kwargs):
|
def wubook_ommit(self, *args, **kwargs):
|
||||||
@@ -49,262 +48,275 @@ class TestHotelWubook(TestHotel):
|
|||||||
wid=False, dfrom=False, dto=False):
|
wid=False, dfrom=False, dto=False):
|
||||||
_logger.info("ISSUE CREATED:\n\t- %s\n\t--- %s", section, message)
|
_logger.info("ISSUE CREATED:\n\t- %s\n\t--- %s", section, message)
|
||||||
|
|
||||||
cls.env['wubook']._patch_method('create_channel_connector_issue',
|
# cls.env['wubook']._patch_method('create_channel_connector_issue',
|
||||||
wubook_create_channel_connector_issue)
|
# wubook_create_channel_connector_issue)
|
||||||
cls.env['wubook']._patch_method('is_valid_account', wubook_ommit)
|
# cls.env['wubook']._patch_method('is_valid_account', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('initialize', wubook_ommit)
|
# cls.env['wubook']._patch_method('initialize', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('push_activation', wubook_ommit)
|
# cls.env['wubook']._patch_method('push_activation', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('init_connection', wubook_ommit)
|
# cls.env['wubook']._patch_method('init_connection', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('close_connection', wubook_ommit)
|
# cls.env['wubook']._patch_method('close_connection', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('create_room', wubook_ommit)
|
# cls.env['wubook']._patch_method('create_room', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('modify_room', wubook_ommit)
|
# cls.env['wubook']._patch_method('modify_room', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('delete_room', wubook_ommit)
|
# cls.env['wubook']._patch_method('delete_room', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('import_rooms', wubook_ommit)
|
# cls.env['wubook']._patch_method('import_rooms', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_rooms_values', wubook_ommit)
|
# cls.env['wubook']._patch_method('fetch_rooms_values', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('update_availability', wubook_ommit)
|
# cls.env['wubook']._patch_method('update_availability', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('corporate_fetch', wubook_ommit)
|
# cls.env['wubook']._patch_method('corporate_fetch', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('create_reservation', wubook_ommit)
|
# cls.env['wubook']._patch_method('create_reservation', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('cancel_reservation', wubook_ommit)
|
# cls.env['wubook']._patch_method('cancel_reservation', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_new_bookings', wubook_ommit)
|
# cls.env['wubook']._patch_method('fetch_new_bookings', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_booking', wubook_ommit)
|
# cls.env['wubook']._patch_method('fetch_booking', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('mark_bookings', wubook_ommit)
|
# cls.env['wubook']._patch_method('mark_bookings', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('create_plan', wubook_ommit)
|
# cls.env['wubook']._patch_method('create_plan', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('delete_plan', wubook_ommit)
|
# cls.env['wubook']._patch_method('delete_plan', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('update_plan_name', wubook_ommit)
|
# cls.env['wubook']._patch_method('update_plan_name', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('update_plan_prices', wubook_ommit)
|
# cls.env['wubook']._patch_method('update_plan_prices', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('update_plan_periods', wubook_ommit)
|
# cls.env['wubook']._patch_method('update_plan_periods', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('import_pricing_plans', wubook_ommit)
|
# cls.env['wubook']._patch_method('import_pricing_plans', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_plan_prices', wubook_ommit)
|
# cls.env['wubook']._patch_method('fetch_plan_prices', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_all_plan_prices', wubook_ommit)
|
# cls.env['wubook']._patch_method('fetch_all_plan_prices', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('import_restriction_plans',
|
# cls.env['wubook']._patch_method('import_restriction_plans',
|
||||||
wubook_ommit)
|
# wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('fetch_rplan_restrictions',
|
# cls.env['wubook']._patch_method('fetch_rplan_restrictions',
|
||||||
wubook_ommit)
|
# wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('update_rplan_values', wubook_ommit)
|
# cls.env['wubook']._patch_method('update_rplan_values', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('create_rplan', wubook_ommit)
|
# cls.env['wubook']._patch_method('create_rplan', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('rename_rplan', wubook_ommit)
|
# cls.env['wubook']._patch_method('rename_rplan', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('delete_rplan', wubook_ommit)
|
# cls.env['wubook']._patch_method('delete_rplan', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('import_channels_info', wubook_ommit)
|
# cls.env['wubook']._patch_method('import_channels_info', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('push_changes', wubook_ommit)
|
# cls.env['wubook']._patch_method('push_changes', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('push_availability', wubook_ommit)
|
# cls.env['wubook']._patch_method('push_availability', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('push_priceplans', wubook_ommit)
|
# cls.env['wubook']._patch_method('push_priceplans', wubook_ommit)
|
||||||
cls.env['wubook']._patch_method('push_restrictions', wubook_ommit)
|
# cls.env['wubook']._patch_method('push_restrictions', wubook_ommit)
|
||||||
|
|
||||||
def create_wubook_booking(self, creator, checkin, partner, rinfo,
|
# def create_wubook_booking(self, creator, checkin, partner, rinfo,
|
||||||
channel=0, notes=''):
|
# channel=0, notes=''):
|
||||||
rcode = randint(100000, 999999)
|
# rcode = randint(100000, 999999)
|
||||||
crcode = randint(100000, 999999)
|
# crcode = randint(100000, 999999)
|
||||||
brate = randint(100000, 999999)
|
# brate = randint(100000, 999999)
|
||||||
id_woodoo = randint(100000, 999999)
|
# id_woodoo = randint(100000, 999999)
|
||||||
|
#
|
||||||
|
# if not partner.email or partner.email == '':
|
||||||
|
# self.raiseException("Partner doesn't have a mail")
|
||||||
|
#
|
||||||
|
# now_utc_dt = date_utils.now()
|
||||||
|
# now_dt = date_utils.dt_as_timezone(now_utc_dt, self.tz_hotel)
|
||||||
|
# checkin_utc_dt = date_utils.get_datetime(checkin)
|
||||||
|
# checkin_dt = date_utils.dt_as_timezone(checkin_utc_dt, self.tz_hotel)
|
||||||
|
# numdays = 0
|
||||||
|
# for k_room, v_room in rinfo.iteritems():
|
||||||
|
# numdays = max(len(v_room['dayprices']), numdays)
|
||||||
|
# checkout_utc_dt = checkin_utc_dt + timedelta(days=numdays)
|
||||||
|
# checkout_dt = date_utils.dt_as_timezone(checkout_utc_dt, self.tz_hotel)
|
||||||
|
# date_diff = date_utils.date_diff(checkin_utc_dt, checkout_utc_dt,
|
||||||
|
# hours=False)
|
||||||
|
#
|
||||||
|
# # Generate Day Prices
|
||||||
|
# dayprices = {}
|
||||||
|
# total_amount = 0.0
|
||||||
|
# for k_room, v_room in rinfo.iteritems():
|
||||||
|
# for price in v_room['dayprices']:
|
||||||
|
# dayprices.setdefault(k_room, []).append(price)
|
||||||
|
# total_amount += price
|
||||||
|
# # Generate Values
|
||||||
|
# rooms = []
|
||||||
|
# rooms_occu = []
|
||||||
|
# booked_rooms = []
|
||||||
|
# room_type_obj = self.env['hotel.room.type']
|
||||||
|
# max_persons = 0
|
||||||
|
# for k_room, v_room in rinfo.iteritems():
|
||||||
|
# room_type = room_type_obj.search([
|
||||||
|
# ('wrid', '=', k_room)
|
||||||
|
# ], limit=1)
|
||||||
|
# # Generate Rooms
|
||||||
|
# for price in range(0, len(v_room['occupancy'])):
|
||||||
|
# rooms.append(k_room)
|
||||||
|
# # Generate Rooms Occupancies
|
||||||
|
# for val in v_room['occupancy']:
|
||||||
|
# # Generate Rooms Occupancies
|
||||||
|
# rooms_occu.append({
|
||||||
|
# 'id': k_room,
|
||||||
|
# 'occupancy': val,
|
||||||
|
# })
|
||||||
|
# # Generate Booked Rooms
|
||||||
|
# roomdays = []
|
||||||
|
# for k_price, v_price in enumerate(v_room['dayprices']):
|
||||||
|
# ndate = checkin_dt + timedelta(days=k_price)
|
||||||
|
# roomdays.append({
|
||||||
|
# 'ancillary': {},
|
||||||
|
# 'rate_id': 3,
|
||||||
|
# 'price': v_price,create_channel_connector_issue
|
||||||
|
# 'day': ndate.strftime(DEFAULT_WUBOOK_DATE_FORMAT)
|
||||||
|
# })
|
||||||
|
# booked_rooms.append({
|
||||||
|
# 'ancillary': {
|
||||||
|
# 'channel_room_id': 1,
|
||||||
|
# 'channel_room_name': room_type.name,
|
||||||
|
# 'addons': [],
|
||||||
|
# 'guests': val
|
||||||
|
# },
|
||||||
|
# 'room_id': k_room,
|
||||||
|
# 'roomdays': roomdays
|
||||||
|
# })
|
||||||
|
# if val > max_persons:
|
||||||
|
# max_persons = val
|
||||||
|
#
|
||||||
|
# return {
|
||||||
|
# 'id_channel': channel,
|
||||||
|
# 'special_offer': '',
|
||||||
|
# 'reservation_code': rcode,
|
||||||
|
# 'dayprices': dayprices,
|
||||||
|
# 'arrival_hour': checkin_dt.strftime(DEFAULT_WUBOOK_TIME_FORMAT),
|
||||||
|
# 'booked_rate': brate,
|
||||||
|
# 'rooms': ','.join(map(str, rooms)),
|
||||||
|
# 'customer_mail': partner.email,
|
||||||
|
# 'customer_country': 'ES',
|
||||||
|
# 'children': 0,
|
||||||
|
# 'payment_gateway_fee': '',
|
||||||
|
# 'modified_reservations': [],
|
||||||
|
# 'customer_surname': ' '.join(partner.name.split(' ')[1:]),
|
||||||
|
# 'date_departure': checkout_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||||
|
# 'amount_reason': '',
|
||||||
|
# 'customer_city': partner.city,
|
||||||
|
# 'opportunities': 0,
|
||||||
|
# 'date_received': now_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||||
|
# 'rooms_occupancies': rooms_occu,
|
||||||
|
# 'sessionSeed': '',
|
||||||
|
# 'booked_rooms': booked_rooms,
|
||||||
|
# 'customer_name': partner.name.split(' ')[0],
|
||||||
|
# 'date_arrival': checkin_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
||||||
|
# 'status': WUBOOK_STATUS_CONFIRMED,
|
||||||
|
# 'was_modified': 0,
|
||||||
|
# 'channel_reservation_code': crcode,
|
||||||
|
# 'men': max_persons,
|
||||||
|
# 'orig_amount': total_amount,
|
||||||
|
# 'customer_phone': partner.mobile or partner.phone or '',
|
||||||
|
# 'customer_notes': notes,
|
||||||
|
# 'customer_address': partner.street,
|
||||||
|
# 'device': -1,
|
||||||
|
# 'addons_list': [],
|
||||||
|
# 'status_reason': '',
|
||||||
|
# 'roomnight': date_diff-1,
|
||||||
|
# 'boards': '',
|
||||||
|
# 'customer_language': 32,
|
||||||
|
# 'fount': '',
|
||||||
|
# 'channel_data': {},
|
||||||
|
# 'room_opportunities': 0,
|
||||||
|
# 'customer_zip': partner.zip,
|
||||||
|
# 'amount': total_amount,
|
||||||
|
# 'id_woodoo': id_woodoo,
|
||||||
|
# 'cc_info': 1,
|
||||||
|
# 'customer_language_iso': 'es'
|
||||||
|
# }
|
||||||
|
|
||||||
if not partner.email or partner.email == '':
|
# def create_wubook_rooms_values(self, rooms, values):
|
||||||
self.raiseException("Partner doesn't have a mail")
|
# json_data = {}
|
||||||
|
# _logger.info("=== PASA AAA")
|
||||||
|
# _logger.info(values)
|
||||||
|
# for room in rooms:
|
||||||
|
# for cvalue in values:
|
||||||
|
# json_data.setdefault(room.wrid, []).append({
|
||||||
|
# 'closed_arrival': cvalue['closed_arrival'],
|
||||||
|
# 'booked': cvalue['booked'],
|
||||||
|
# 'max_stay_arrival': cvalue['max_stay_arrival'],
|
||||||
|
# 'max_stay': cvalue['max_stay'],
|
||||||
|
# 'price': cvalue['price'],
|
||||||
|
# 'min_stay': cvalue['min_stay'],
|
||||||
|
# 'closed_departure': cvalue['closed_departure'],
|
||||||
|
# 'avail': cvalue['avail'],
|
||||||
|
# 'closed': cvalue['closed'],
|
||||||
|
# 'min_stay_arrival': cvalue['min_stay_arrival'],
|
||||||
|
# 'no_ota': cvalue['no_ota'],
|
||||||
|
# })
|
||||||
|
# return json_data
|
||||||
|
|
||||||
now_utc_dt = date_utils.now()
|
# def cancel_booking(self, wbooking):
|
||||||
now_dt = date_utils.dt_as_timezone(now_utc_dt, self.tz_hotel)
|
# wbooking['status'] = WUBOOK_STATUS_CANCELLED
|
||||||
checkin_utc_dt = date_utils.get_datetime(checkin)
|
# return wbooking
|
||||||
checkin_dt = date_utils.dt_as_timezone(checkin_utc_dt, self.tz_hotel)
|
|
||||||
numdays = 0
|
|
||||||
for k_room, v_room in rinfo.iteritems():
|
|
||||||
numdays = max(len(v_room['dayprices']), numdays)
|
|
||||||
checkout_utc_dt = checkin_utc_dt + timedelta(days=numdays)
|
|
||||||
checkout_dt = date_utils.dt_as_timezone(checkout_utc_dt, self.tz_hotel)
|
|
||||||
date_diff = date_utils.date_diff(checkin_utc_dt, checkout_utc_dt,
|
|
||||||
hours=False)
|
|
||||||
|
|
||||||
# Generate Day Prices
|
|
||||||
dayprices = {}
|
|
||||||
total_amount = 0.0
|
|
||||||
for k_room, v_room in rinfo.iteritems():
|
|
||||||
for price in v_room['dayprices']:
|
|
||||||
dayprices.setdefault(k_room, []).append(price)
|
|
||||||
total_amount += price
|
|
||||||
# Generate Values
|
|
||||||
rooms = []
|
|
||||||
rooms_occu = []
|
|
||||||
booked_rooms = []
|
|
||||||
room_type_obj = self.env['hotel.room.type']
|
|
||||||
max_persons = 0
|
|
||||||
for k_room, v_room in rinfo.iteritems():
|
|
||||||
room_type = room_type_obj.search([
|
|
||||||
('wrid', '=', k_room)
|
|
||||||
], limit=1)
|
|
||||||
# Generate Rooms
|
|
||||||
for price in range(0, len(v_room['occupancy'])):
|
|
||||||
rooms.append(k_room)
|
|
||||||
# Generate Rooms Occupancies
|
|
||||||
for val in v_room['occupancy']:
|
|
||||||
# Generate Rooms Occupancies
|
|
||||||
rooms_occu.append({
|
|
||||||
'id': k_room,
|
|
||||||
'occupancy': val,
|
|
||||||
})
|
|
||||||
# Generate Booked Rooms
|
|
||||||
roomdays = []
|
|
||||||
for k_price, v_price in enumerate(v_room['dayprices']):
|
|
||||||
ndate = checkin_dt + timedelta(days=k_price)
|
|
||||||
roomdays.append({
|
|
||||||
'ancillary': {},
|
|
||||||
'rate_id': 3,
|
|
||||||
'price': v_price,
|
|
||||||
'day': ndate.strftime(DEFAULT_WUBOOK_DATE_FORMAT)
|
|
||||||
})
|
|
||||||
booked_rooms.append({
|
|
||||||
'ancillary': {
|
|
||||||
'channel_room_id': 1,
|
|
||||||
'channel_room_name': room_type.name,
|
|
||||||
'addons': [],
|
|
||||||
'guests': val
|
|
||||||
},
|
|
||||||
'room_id': k_room,
|
|
||||||
'roomdays': roomdays
|
|
||||||
})
|
|
||||||
if val > max_persons:
|
|
||||||
max_persons = val
|
|
||||||
|
|
||||||
return {
|
|
||||||
'id_channel': channel,
|
|
||||||
'special_offer': '',
|
|
||||||
'reservation_code': rcode,
|
|
||||||
'dayprices': dayprices,
|
|
||||||
'arrival_hour': checkin_dt.strftime(DEFAULT_WUBOOK_TIME_FORMAT),
|
|
||||||
'booked_rate': brate,
|
|
||||||
'rooms': ','.join(map(str, rooms)),
|
|
||||||
'customer_mail': partner.email,
|
|
||||||
'customer_country': 'ES',
|
|
||||||
'children': 0,
|
|
||||||
'payment_gateway_fee': '',
|
|
||||||
'modified_reservations': [],
|
|
||||||
'customer_surname': ' '.join(partner.name.split(' ')[1:]),
|
|
||||||
'date_departure': checkout_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
|
||||||
'amount_reason': '',
|
|
||||||
'customer_city': partner.city,
|
|
||||||
'opportunities': 0,
|
|
||||||
'date_received': now_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
|
||||||
'rooms_occupancies': rooms_occu,
|
|
||||||
'sessionSeed': '',
|
|
||||||
'booked_rooms': booked_rooms,
|
|
||||||
'customer_name': partner.name.split(' ')[0],
|
|
||||||
'date_arrival': checkin_dt.strftime(DEFAULT_WUBOOK_DATE_FORMAT),
|
|
||||||
'status': WUBOOK_STATUS_CONFIRMED,
|
|
||||||
'was_modified': 0,
|
|
||||||
'channel_reservation_code': crcode,
|
|
||||||
'men': max_persons,
|
|
||||||
'orig_amount': total_amount,
|
|
||||||
'customer_phone': partner.mobile or partner.phone or '',
|
|
||||||
'customer_notes': notes,
|
|
||||||
'customer_address': partner.street,
|
|
||||||
'device': -1,
|
|
||||||
'addons_list': [],
|
|
||||||
'status_reason': '',
|
|
||||||
'roomnight': date_diff-1,
|
|
||||||
'boards': '',
|
|
||||||
'customer_language': 32,
|
|
||||||
'fount': '',
|
|
||||||
'channel_data': {},
|
|
||||||
'room_opportunities': 0,
|
|
||||||
'customer_zip': partner.zip,
|
|
||||||
'amount': total_amount,
|
|
||||||
'id_woodoo': id_woodoo,
|
|
||||||
'cc_info': 1,
|
|
||||||
'customer_language_iso': 'es'
|
|
||||||
}
|
|
||||||
|
|
||||||
def create_wubook_rooms_values(self, rooms, values):
|
|
||||||
json_data = {}
|
|
||||||
_logger.info("=== PASA AAA")
|
|
||||||
_logger.info(values)
|
|
||||||
for room in rooms:
|
|
||||||
for cvalue in values:
|
|
||||||
json_data.setdefault(room.wrid, []).append({
|
|
||||||
'closed_arrival': cvalue['closed_arrival'],
|
|
||||||
'booked': cvalue['booked'],
|
|
||||||
'max_stay_arrival': cvalue['max_stay_arrival'],
|
|
||||||
'max_stay': cvalue['max_stay'],
|
|
||||||
'price': cvalue['price'],
|
|
||||||
'min_stay': cvalue['min_stay'],
|
|
||||||
'closed_departure': cvalue['closed_departure'],
|
|
||||||
'avail': cvalue['avail'],
|
|
||||||
'closed': cvalue['closed'],
|
|
||||||
'min_stay_arrival': cvalue['min_stay_arrival'],
|
|
||||||
'no_ota': cvalue['no_ota'],
|
|
||||||
})
|
|
||||||
return json_data
|
|
||||||
|
|
||||||
def cancel_booking(self, wbooking):
|
|
||||||
wbooking['status'] = WUBOOK_STATUS_CANCELLED
|
|
||||||
return wbooking
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
super(TestHotelWubook, cls).setUpClass()
|
super().setUpClass()
|
||||||
|
|
||||||
# Update Test Virtual Rooms
|
cls.manager_hotel_demo = cls.env.ref('base.user_demo')
|
||||||
cls.hotel_room_type_budget.write({
|
cls.manager_hotel_demo.groups_id += cls.env.ref('hotel.group_hotel_manager')
|
||||||
'wcapacity': 1,
|
|
||||||
'wrid': 3000,
|
# Create a fake channel connector with WuBook
|
||||||
'wscode': 'T001',
|
cls.channel_connector_wubook = cls.env['channel.backend'].create({
|
||||||
})
|
'version': '1.1',
|
||||||
cls.hotel_room_type_special.write({
|
'lcode': 123456789,
|
||||||
'wcapacity': 2,
|
'pkey': 'YourProviderKey',
|
||||||
'wrid': 3001,
|
'server': 'https://wired.wubook.net/xrws/'
|
||||||
'wscode': 'T002',
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Update Hotel Test Room Type Records
|
||||||
|
# cls.room_type_0.write({
|
||||||
|
# 'ota_capacity': 2,
|
||||||
|
# 'wrid': 3000,
|
||||||
|
# 'shortname': 'T000',
|
||||||
|
# # }) # formerly named hotel_room_type_budget
|
||||||
|
# cls.room_type_0.write({
|
||||||
|
# 'ota_capacity': 1,
|
||||||
|
# 'wrid': 3001,
|
||||||
|
# 'shortname': 'T001',
|
||||||
|
# }) # formerly named hotel_room_type_budget
|
||||||
|
# cls.room_type_0.write({
|
||||||
|
# 'ota_capacity': 2,
|
||||||
|
# 'wrid': 3002,
|
||||||
|
# 'shortname': 'T002',
|
||||||
|
# }) # formerly named hotel_room_type_special
|
||||||
|
|
||||||
# Update Restriction
|
# Update Restriction
|
||||||
room_type_restr_obj = cls.env['hotel.room.type.restriction']
|
# room_type_restr_obj = cls.env['hotel.room.type.restriction']
|
||||||
default_restriction = room_type_restr_obj.search([
|
# default_restriction = room_type_restr_obj.search([
|
||||||
('wpid', '=', '0')
|
# ('wpid', '=', '0')
|
||||||
], limit=1)
|
# ], limit=1)
|
||||||
if default_restriction:
|
# if default_restriction:
|
||||||
cls.restriction_default_id = default_restriction.id
|
# cls.restriction_default_id = default_restriction.id
|
||||||
else:
|
# else:
|
||||||
cls.restriction_1.write({
|
# cls.restriction_1.write({
|
||||||
'wpid': '0'
|
# 'wpid': '0'
|
||||||
})
|
# })
|
||||||
cls.restriction_default_id = cls.restriction_1.id
|
# cls.restriction_default_id = cls.restriction_1.id
|
||||||
|
|
||||||
|
# Create Wubook Channel Info
|
||||||
|
|
||||||
# Create Some Wubook Info
|
|
||||||
cls.wubook_channel_test = cls.env['wubook.channel.info'].create({
|
|
||||||
'wid': 1,
|
|
||||||
'name': 'Channel Test'
|
|
||||||
})
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
# Remove mocks
|
# Remove mocks
|
||||||
cls.env['wubook']._revert_method('create_channel_connector_issue')
|
# cls.env['wubook']._revert_method('create_channel_connector_issue')
|
||||||
cls.env['wubook']._revert_method('is_valid_account')
|
# cls.env['wubook']._revert_method('is_valid_account')
|
||||||
cls.env['wubook']._revert_method('initialize')
|
# cls.env['wubook']._revert_method('initialize')
|
||||||
cls.env['wubook']._revert_method('push_activation')
|
# cls.env['wubook']._revert_method('push_activation')
|
||||||
cls.env['wubook']._revert_method('init_connection')
|
# cls.env['wubook']._revert_method('init_connection')
|
||||||
cls.env['wubook']._revert_method('close_connection')
|
# cls.env['wubook']._revert_method('close_connection')
|
||||||
cls.env['wubook']._revert_method('create_room')
|
# cls.env['wubook']._revert_method('create_room')
|
||||||
cls.env['wubook']._revert_method('modify_room')
|
# cls.env['wubook']._revert_method('modify_room')
|
||||||
cls.env['wubook']._revert_method('delete_room')
|
# cls.env['wubook']._revert_method('delete_room')
|
||||||
cls.env['wubook']._revert_method('import_rooms')
|
# cls.env['wubook']._revert_method('import_rooms')
|
||||||
cls.env['wubook']._revert_method('fetch_rooms_values')
|
# cls.env['wubook']._revert_method('fetch_rooms_values')
|
||||||
cls.env['wubook']._revert_method('update_availability')
|
# cls.env['wubook']._revert_method('update_availability')
|
||||||
cls.env['wubook']._revert_method('corporate_fetch')
|
# cls.env['wubook']._revert_method('corporate_fetch')
|
||||||
cls.env['wubook']._revert_method('create_reservation')
|
# cls.env['wubook']._revert_method('create_reservation')
|
||||||
cls.env['wubook']._revert_method('cancel_reservation')
|
# cls.env['wubook']._revert_method('cancel_reservation')
|
||||||
cls.env['wubook']._revert_method('fetch_new_bookings')
|
# cls.env['wubook']._revert_method('fetch_new_bookings')
|
||||||
cls.env['wubook']._revert_method('fetch_booking')
|
# cls.env['wubook']._revert_method('fetch_booking')
|
||||||
cls.env['wubook']._revert_method('mark_bookings')
|
# cls.env['wubook']._revert_method('mark_bookings')
|
||||||
cls.env['wubook']._revert_method('create_plan')
|
# cls.env['wubook']._revert_method('create_plan')
|
||||||
cls.env['wubook']._revert_method('delete_plan')
|
# cls.env['wubook']._revert_method('delete_plan')
|
||||||
cls.env['wubook']._revert_method('update_plan_name')
|
# cls.env['wubook']._revert_method('update_plan_name')
|
||||||
cls.env['wubook']._revert_method('update_plan_prices')
|
# cls.env['wubook']._revert_method('update_plan_prices')
|
||||||
cls.env['wubook']._revert_method('update_plan_periods')
|
# cls.env['wubook']._revert_method('update_plan_periods')
|
||||||
cls.env['wubook']._revert_method('import_pricing_plans')
|
# cls.env['wubook']._revert_method('import_pricing_plans')
|
||||||
cls.env['wubook']._revert_method('fetch_plan_prices')
|
# cls.env['wubook']._revert_method('fetch_plan_prices')
|
||||||
cls.env['wubook']._revert_method('fetch_all_plan_prices')
|
# cls.env['wubook']._revert_method('fetch_all_plan_prices')
|
||||||
cls.env['wubook']._revert_method('import_restriction_plans')
|
# cls.env['wubook']._revert_method('import_restriction_plans')
|
||||||
cls.env['wubook']._revert_method('fetch_rplan_restrictions')
|
# cls.env['wubook']._revert_method('fetch_rplan_restrictions')
|
||||||
cls.env['wubook']._revert_method('update_rplan_values')
|
# cls.env['wubook']._revert_method('update_rplan_values')
|
||||||
cls.env['wubook']._revert_method('create_rplan')
|
# cls.env['wubook']._revert_method('create_rplan')
|
||||||
cls.env['wubook']._revert_method('rename_rplan')
|
# cls.env['wubook']._revert_method('rename_rplan')
|
||||||
cls.env['wubook']._revert_method('delete_rplan')
|
# cls.env['wubook']._revert_method('delete_rplan')
|
||||||
cls.env['wubook']._revert_method('import_channels_info')
|
# cls.env['wubook']._revert_method('import_channels_info')
|
||||||
|
|
||||||
super(TestHotelWubook, cls).tearDownClass()
|
super().tearDownClass()
|
||||||
@@ -20,28 +20,25 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from datetime import timedelta
|
|
||||||
from odoo.tools import (
|
from odoo.tools import (
|
||||||
DEFAULT_SERVER_DATETIME_FORMAT,
|
DEFAULT_SERVER_DATETIME_FORMAT,
|
||||||
DEFAULT_SERVER_DATE_FORMAT)
|
DEFAULT_SERVER_DATE_FORMAT)
|
||||||
from odoo.exceptions import AccessError
|
from odoo.exceptions import AccessError
|
||||||
from .common import TestChannelConnectorWubook
|
from .common import TestHotelWubook
|
||||||
|
|
||||||
|
|
||||||
class TestChannelRoomType(TestChannelConnectorWubook):
|
class TestChannelRoomType(TestHotelWubook):
|
||||||
|
|
||||||
def create_room(self, shortcode, name, capacity, price, availability, defboard, rtype):
|
def test_create_room(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def fetch_rooms(self):
|
def test_fetch_rooms(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def modify_room(self, channel_room_id, name, capacity, price, availability, scode, defboard, rtype):
|
def test_modify_room(self):
|
||||||
import wdb; wdb.set_trace()
|
|
||||||
self.hotel_room_type_simple.ota_capacity = 1
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def delete_room(self, channel_room_id):
|
def test_delete_room(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# def test_get_capacity(self):
|
# def test_get_capacity(self):
|
||||||
Reference in New Issue
Block a user