From 86af9609f17a8e34004faa991854f62d3361685f Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Tue, 16 Jul 2013 18:53:41 +0300 Subject: Reorganized tests --- gsxws/objectify.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'gsxws/objectify.py') diff --git a/gsxws/objectify.py b/gsxws/objectify.py index fd6ceda..3a48858 100644 --- a/gsxws/objectify.py +++ b/gsxws/objectify.py @@ -4,6 +4,7 @@ import os import re import base64 import tempfile + from lxml import objectify, etree from lxml.objectify import StringElement @@ -11,7 +12,8 @@ from datetime import datetime BASE64_TYPES = ('packingList', 'proformaFileData', 'returnLabelFileData',) FLOAT_TYPES = ('totalFromOrder', 'exchangePrice', 'stockPrice', 'netPrice',) -BOOLEAN_TYPES = ('isSerialized', 'popMandatory', 'limitedWarranty', 'partCovered',) +BOOLEAN_TYPES = ('isSerialized', 'popMandatory', 'limitedWarranty', 'partCovered', 'acPlusFlag',) +DATETIME_TYPES = ('dispatchSentDate',) TZMAP = { 'GMT': '', # Greenwich Mean Time @@ -41,6 +43,9 @@ class GsxElement(StringElement): def __str__(self): return unicode(self).encode('utf-8') + def __repr__(self): + return str(self.text) + class GsxDateElement(GsxElement): @property @@ -100,10 +105,8 @@ class GsxTimestampElement(GsxElement): class GsxClassLookup(etree.CustomElementClassLookup): def lookup(self, node_type, document, namespace, name): - if name == 'dispatchSentDate': + if name in DATETIME_TYPES: return GsxDatetimeElement - if name == 'acPlusFlag': - return GsxBooleanElement if name in BOOLEAN_TYPES: return GsxBooleanElement if name in BASE64_TYPES: @@ -117,10 +120,6 @@ class GsxClassLookup(etree.CustomElementClassLookup): def parse(root, response): - """ - >>> parse('../tests/warranty_status.xml', 'warrantyDetailInfo').estimatedPurchaseDate - 2010-08-25 - """ parser = objectify.makeparser(remove_blank_text=True) parser.set_element_class_lookup(GsxClassLookup()) -- cgit v1.2.3