From 5f6da8bfcfd2ad8380815b6b5f309c9985873eb1 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 13 May 2013 18:44:29 +0300 Subject: More to_xml nesting fixes! --- gsxws/core.py | 14 ++++++++------ gsxws/products.py | 2 +- gsxws/repairs.py | 33 ++++++++++----------------------- tests/create_carryin_repair.json | 8 ++++++++ 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/gsxws/core.py b/gsxws/core.py index 59f23dd..c8f9cec 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -336,15 +336,17 @@ class GsxObject(object): """ root = ET.Element(root) for k, v in self._data.items(): - el = ET.SubElement(root, k) - if isinstance(v, basestring): - el.text = v - if isinstance(v, GsxObject): - el.append(v.to_xml(k)) if isinstance(v, list): for e in v: if isinstance(e, GsxObject): - el.append(e.to_xml(k)) + i = ET.SubElement(root, k) + i.extend(e.to_xml(k)) + else: + el = ET.SubElement(root, k) + if isinstance(v, basestring): + el.text = v + if isinstance(v, GsxObject): + el.extend(v.to_xml(k)) return root diff --git a/gsxws/products.py b/gsxws/products.py index f77957d..f51a338 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -83,7 +83,7 @@ class Product(GsxObject): The Fetch iOS Activation Details API is used to fetch activation details of iOS Devices. - >>> Product('013348005376007').get_activation().unlocked + >>> Product('013348005376007').activation().unlocked 'true' >>> Product('W874939YX92').get_activation().unlocked # doctest: +ELLIPSIS Traceback (most recent call last): diff --git a/gsxws/repairs.py b/gsxws/repairs.py index 2a17144..c411174 100644 --- a/gsxws/repairs.py +++ b/gsxws/repairs.py @@ -6,6 +6,15 @@ import logging from core import GsxObject from lookups import Lookup +REPAIR_TYPES = ( + ('CA', "Carry-In/Non-Replinished"), + ('NE', "Return Before Replace"), + ('NT', "No Trouble Found"), + ('ON', "Onsite (Indirect/Direct)"), + ('RR', "Repair Or Replace/Whole Unit Mail-In"), + ('WH', "Mail-In"), +) + class Customer(GsxObject): """ @@ -35,30 +44,8 @@ class RepairOrderLine(GsxObject): class Repair(GsxObject): "Base class for the different GSX Repair types" - notes = "" - symptom = "" - diagnosis = "" - serialNumber = "" - referenceNumber = "" - unitReceivedDate = "" - unitReceivedTime = "" - requestReview = False - customerAddress = None - purchaseOrderNumber = "" - - orderLines = [] - _namespace = "asp:" - TYPES = ( - ('CA', "Carry-In/Non-Replinished"), - ('NE', "Return Before Replace"), - ('NT', "No Trouble Found"), - ('ON', "Onsite (Indirect/Direct)"), - ('RR', "Repair Or Replace/Whole Unit Mail-In"), - ('WH', "Mail-In"), - ) - def __init__(self, number=None, **kwargs): super(Repair, self).__init__(**kwargs) @@ -143,7 +130,7 @@ class Repair(GsxObject): for the submitted repair confirmation number(s). >>> Repair('G135773004').status().repairStatus - 'Closed and Completed' + u'Closed and Completed' """ self.repairConfirmationNumbers = self.dispatchId status = self._submit("RepairStatusRequest", "RepairStatus", "repairStatus")[0] diff --git a/tests/create_carryin_repair.json b/tests/create_carryin_repair.json index 685b7d4..059ad93 100644 --- a/tests/create_carryin_repair.json +++ b/tests/create_carryin_repair.json @@ -16,6 +16,14 @@ "abused": "Y", "outOfWarrantyFlag": "N", "diagnosticCode": "" + }, + { + "partNumber": "076-1080", + "comptiaCode": "660", + "comptiaModifier": "A", + "abused": "Y", + "outOfWarrantyFlag": "N", + "diagnosticCode": "" } ], "customerAddress": { -- cgit v1.2.3