aboutsummaryrefslogtreecommitdiffstats
path: root/gsxws/objectify.py
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-07-16 18:53:41 +0300
committerFilipp Lepalaan <f@230.to>2013-07-16 18:53:41 +0300
commit86af9609f17a8e34004faa991854f62d3361685f (patch)
tree6f678b6ebb7e24cf0760d9747ac84182af230f5e /gsxws/objectify.py
parent4d9c2b0a47dd9336d9df7222013ade0c1763856d (diff)
downloadpy-gsxws-86af9609f17a8e34004faa991854f62d3361685f.tar.gz
py-gsxws-86af9609f17a8e34004faa991854f62d3361685f.tar.bz2
py-gsxws-86af9609f17a8e34004faa991854f62d3361685f.zip
Reorganized tests
Diffstat (limited to 'gsxws/objectify.py')
-rw-r--r--gsxws/objectify.py15
1 files changed, 7 insertions, 8 deletions
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())