def test_add_child(self): parent = XmlNode('Parent') child = parent.add_child(XmlNode('Child')) self.assertEqual(str(parent), '<Parent><Child/></Parent>') child.set_attribute('hasParent', 'True') child.parent.set_attribute('hasChildren', 'True') self.assertEqual(str(parent), '<Parent hasChildren="True"><Child hasParent="True"/></Parent>')
def __init__(self, *args, **kwargs): XmlNode.__init__(self, *args, **kwargs) self._stay_date_range = None self._room_stay_candidates = None self._rate_plan_candidates = None self._rate_range = None self._tpa_extensions = None
def __init__(self, hotel_code=None, hotel_code_context=None, **kwargs): XmlNode.__init__(self, **kwargs) self._hotel_code = None self._hotel_code_context = None if hotel_code: self.hotel_code = hotel_code if hotel_code_context: self.hotel_code_context = hotel_code_context
def test_add_child(self): parent = XmlNode('Parent') child = parent.add_child(XmlNode('Child')) self.assertEqual(str(parent), '<Parent><Child/></Parent>') child.set_attribute('hasParent', 'True') child.parent.set_attribute('hasChildren', 'True') self.assertEqual( str(parent), '<Parent hasChildren="True"><Child hasParent="True"/></Parent>')
def test_init_node(self): raw_node = XmlNode() self.assertEqual(str(raw_node), '<XmlNode/>') raw_node = XmlNode(one=1) self.assertEqual(str(raw_node), '<XmlNode one="1"/>') attr = {'one': 1} raw_node = XmlNode(**attr) self.assertEqual(str(raw_node), '<XmlNode one="1"/>') raw_node = XmlNode('Name') self.assertEqual(str(raw_node), '<Name/>') raw_node = XmlNode('Name', **attr) self.assertEqual(str(raw_node), '<Name one="1"/>')
def __init__(self, **kwargs): kwargs[constants.XMLNS] = "http://www.opentravel.org/OTA/2003/05" url = "http://www.w3.org/2001/XMLSchema-instance" kwargs[constants.XMLNS_XSI] = url url = "http://www.opentravel.org/OTA/2003/05 OTA_HotelAvailRQ.xsd" kwargs[constants.XSI_SCHEMALOCATION] = url XmlNode.__init__(self, constants.OTA_HOTELAVAILRQ, **kwargs) self.pos = self.add_child(POS()) avl_req_segs_node = XmlNode(constants.AVAIL_REQUEST_SEGMENTS) avl_req_segs = self.add_child(avl_req_segs_node) avl_req_seg_node = XmlNode(constants.AVAIL_REQUEST_SEGMENT) avl_req_seg = avl_req_segs.add_child(avl_req_seg_node) hsc_node = XmlNode(constants.HOTEL_SEARCH_CRITERIA) self._hotel_search_criteria = avl_req_seg.add_child(hsc_node)
def test_set_attribute(self): raw_node = XmlNode() raw_node.set_attribute('two', 2) self.assertEqual(str(raw_node), '<XmlNode two="2"/>') raw_node.set_attribute('two', 3) self.assertEqual(str(raw_node), '<XmlNode two="3"/>') raw_node.set_attribute('two', 'TWO') self.assertEqual(str(raw_node), '<XmlNode two="TWO"/>')
def _set_guest_count(self, age_code, count): if age_code not in self._age_map.keys(): guest_count = XmlNode(constants.GUEST_COUNT) self._age_map[age_code] = self._guest_counts.add_child(guest_count) guest_count = self._age_map[age_code] guest_count.set_attribute(constants.AGE_QUALIFYING_CODE, age_code) guest_count.set_attribute(constants.COUNT, count)
def _get_room_stay_candidates(self): if not self._room_stay_candidates: room_stay = XmlNode(constants.ROOM_STAY_CANDIDATES) self._room_stay_candidates = self.add_child(room_stay) return self._room_stay_candidates
def __init__(self, **kwargs): XmlNode.__init__(self, **kwargs) self._company_name = None
def __init__(self, *args, **kwargs): XmlNode.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): XmlNode.__init__(self, *args, **kwargs) self._guest_counts = self.add_child(XmlNode(constants.GUEST_COUNTS)) self._age_map = {}
def test_add_text(self): raw_node = XmlNode() raw_node.add_text('RAW') self.assertEqual(str(raw_node), '<XmlNode>RAW</XmlNode>')
def __init__(self, *args, **kwargs): XmlNode.__init__(self, *args, **kwargs) self.origin = self.add_child(Source()) self.office = self.add_child(Source())
def _get_rate_plan_candidates(self): if not self._rate_plan_candidates: rate_plan = XmlNode(constants.RATE_PLAN_CANDIDATES) self._rate_plan_candidates = self.add_child(rate_plan) return self._rate_plan_candidates
def __init__(self, *args, **kwargs): XmlNode.__init__(self, *args, **kwargs) self.requestor_id = self.add_child(RequestorID()) self._booking_channel = None
def get_company_name(self): if not self._company_name: self._company_name = self.add_child(XmlNode(constants.COMPANY_NAME)) return self._company_name
def add_price_group_criterion(self, name): group_criterion_node = XmlNode(constants.GROUP_CRITERION) group_criterion = self.price_group.add_child(group_criterion_node) group_criterion.set_attribute(constants.NAME, name) return group_criterion
def _get_price_group(self): if not self._price_group: self._price_group = self.add_child(XmlNode(constants.PRICE_GROUP)) return self._price_group
def __init__(self, **kwargs): XmlNode.__init__(self, constants.TPA_EXTENSIONS, **kwargs) self._price_group = None