diff options
author | Filipp Lepalaan <f@230.to> | 2013-07-16 18:53:41 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-07-16 18:53:41 +0300 |
commit | 86af9609f17a8e34004faa991854f62d3361685f (patch) | |
tree | 6f678b6ebb7e24cf0760d9747ac84182af230f5e | |
parent | 4d9c2b0a47dd9336d9df7222013ade0c1763856d (diff) | |
download | py-gsxws-86af9609f17a8e34004faa991854f62d3361685f.tar.gz py-gsxws-86af9609f17a8e34004faa991854f62d3361685f.tar.bz2 py-gsxws-86af9609f17a8e34004faa991854f62d3361685f.zip |
Reorganized tests
-rw-r--r-- | gsxws/objectify.py | 15 | ||||
-rw-r--r-- | tests/__init__.py | 0 | ||||
-rw-r--r-- | tests/fixtures/acknowledge_communication.json (renamed from tests/acknowledge_communication.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_app_order.json (renamed from tests/create_app_order.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_carryin_repair.json (renamed from tests/create_carryin_repair.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_cnd_repair.json (renamed from tests/create_cnd_repair.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_escalation.json (renamed from tests/create_escalation.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_srf_order.json (renamed from tests/create_srf_order.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_stocking_order.json (renamed from tests/create_stocking_order.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/create_whole_unit_exchange.json (renamed from tests/create_whole_unit_exchange.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/fetch_communication_articles.json (renamed from tests/fetch_communication_articles.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/fetch_communication_content.json (renamed from tests/fetch_communication_content.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/fetch_ios_activation.json (renamed from tests/fetch_ios_activation.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/parts_lookup.json (renamed from tests/parts_lookup.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/parts_pending_return.json (renamed from tests/parts_pending_return.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/parts_register_return.json (renamed from tests/parts_register_return.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/parts_return_update.json (renamed from tests/parts_return_update.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/pending_app_orders.json (renamed from tests/pending_app_orders.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/register_bulk_return.json (renamed from tests/register_bulk_return.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/repair_lookup.json (renamed from tests/repair_lookup.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/return_label.json (renamed from tests/return_label.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/return_report.json (renamed from tests/return_report.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/update_carryin_repair.json (renamed from tests/update_carryin_repair.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/update_escalation.json (renamed from tests/update_escalation.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/update_serial_number.json (renamed from tests/update_serial_number.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/warranty_status.json (renamed from tests/warranty_status.json) | 0 | ||||
-rw-r--r-- | tests/fixtures/warranty_status.xml (renamed from tests/warranty_status.xml) | 0 | ||||
-rw-r--r-- | tests/test_gsxws.py | 21 |
28 files changed, 28 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()) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/acknowledge_communication.json b/tests/fixtures/acknowledge_communication.json index 5fd7b9b..5fd7b9b 100644 --- a/tests/acknowledge_communication.json +++ b/tests/fixtures/acknowledge_communication.json diff --git a/tests/create_app_order.json b/tests/fixtures/create_app_order.json index 1d1bba8..1d1bba8 100644 --- a/tests/create_app_order.json +++ b/tests/fixtures/create_app_order.json diff --git a/tests/create_carryin_repair.json b/tests/fixtures/create_carryin_repair.json index 059ad93..059ad93 100644 --- a/tests/create_carryin_repair.json +++ b/tests/fixtures/create_carryin_repair.json diff --git a/tests/create_cnd_repair.json b/tests/fixtures/create_cnd_repair.json index c46d8c1..c46d8c1 100644 --- a/tests/create_cnd_repair.json +++ b/tests/fixtures/create_cnd_repair.json diff --git a/tests/create_escalation.json b/tests/fixtures/create_escalation.json index 3e1ac9c..3e1ac9c 100644 --- a/tests/create_escalation.json +++ b/tests/fixtures/create_escalation.json diff --git a/tests/create_srf_order.json b/tests/fixtures/create_srf_order.json index 7a58344..7a58344 100644 --- a/tests/create_srf_order.json +++ b/tests/fixtures/create_srf_order.json diff --git a/tests/create_stocking_order.json b/tests/fixtures/create_stocking_order.json index 1af23a4..1af23a4 100644 --- a/tests/create_stocking_order.json +++ b/tests/fixtures/create_stocking_order.json diff --git a/tests/create_whole_unit_exchange.json b/tests/fixtures/create_whole_unit_exchange.json index b7e77e2..b7e77e2 100644 --- a/tests/create_whole_unit_exchange.json +++ b/tests/fixtures/create_whole_unit_exchange.json diff --git a/tests/fetch_communication_articles.json b/tests/fixtures/fetch_communication_articles.json index d5a0674..d5a0674 100644 --- a/tests/fetch_communication_articles.json +++ b/tests/fixtures/fetch_communication_articles.json diff --git a/tests/fetch_communication_content.json b/tests/fixtures/fetch_communication_content.json index cb28cb2..cb28cb2 100644 --- a/tests/fetch_communication_content.json +++ b/tests/fixtures/fetch_communication_content.json diff --git a/tests/fetch_ios_activation.json b/tests/fixtures/fetch_ios_activation.json index 4b73647..4b73647 100644 --- a/tests/fetch_ios_activation.json +++ b/tests/fixtures/fetch_ios_activation.json diff --git a/tests/parts_lookup.json b/tests/fixtures/parts_lookup.json index b271e16..b271e16 100644 --- a/tests/parts_lookup.json +++ b/tests/fixtures/parts_lookup.json diff --git a/tests/parts_pending_return.json b/tests/fixtures/parts_pending_return.json index 91e8ad2..91e8ad2 100644 --- a/tests/parts_pending_return.json +++ b/tests/fixtures/parts_pending_return.json diff --git a/tests/parts_register_return.json b/tests/fixtures/parts_register_return.json index c8a49ae..c8a49ae 100644 --- a/tests/parts_register_return.json +++ b/tests/fixtures/parts_register_return.json diff --git a/tests/parts_return_update.json b/tests/fixtures/parts_return_update.json index 5cdefee..5cdefee 100644 --- a/tests/parts_return_update.json +++ b/tests/fixtures/parts_return_update.json diff --git a/tests/pending_app_orders.json b/tests/fixtures/pending_app_orders.json index ec49768..ec49768 100644 --- a/tests/pending_app_orders.json +++ b/tests/fixtures/pending_app_orders.json diff --git a/tests/register_bulk_return.json b/tests/fixtures/register_bulk_return.json index 3b6bda8..3b6bda8 100644 --- a/tests/register_bulk_return.json +++ b/tests/fixtures/register_bulk_return.json diff --git a/tests/repair_lookup.json b/tests/fixtures/repair_lookup.json index 12f35a6..12f35a6 100644 --- a/tests/repair_lookup.json +++ b/tests/fixtures/repair_lookup.json diff --git a/tests/return_label.json b/tests/fixtures/return_label.json index edebf48..edebf48 100644 --- a/tests/return_label.json +++ b/tests/fixtures/return_label.json diff --git a/tests/return_report.json b/tests/fixtures/return_report.json index a868dd3..a868dd3 100644 --- a/tests/return_report.json +++ b/tests/fixtures/return_report.json diff --git a/tests/update_carryin_repair.json b/tests/fixtures/update_carryin_repair.json index 90ee39e..90ee39e 100644 --- a/tests/update_carryin_repair.json +++ b/tests/fixtures/update_carryin_repair.json diff --git a/tests/update_escalation.json b/tests/fixtures/update_escalation.json index cd46995..cd46995 100644 --- a/tests/update_escalation.json +++ b/tests/fixtures/update_escalation.json diff --git a/tests/update_serial_number.json b/tests/fixtures/update_serial_number.json index 789bdf6..789bdf6 100644 --- a/tests/update_serial_number.json +++ b/tests/fixtures/update_serial_number.json diff --git a/tests/warranty_status.json b/tests/fixtures/warranty_status.json index 9d02027..9d02027 100644 --- a/tests/warranty_status.json +++ b/tests/fixtures/warranty_status.json diff --git a/tests/warranty_status.xml b/tests/fixtures/warranty_status.xml index 9712590..9712590 100644 --- a/tests/warranty_status.xml +++ b/tests/fixtures/warranty_status.xml diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py new file mode 100644 index 0000000..d7feac6 --- /dev/null +++ b/tests/test_gsxws.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- + +import unittest +from datetime import date + +from gsxws.objectify import parse + + +class TestWarrantyFunctions(unittest.TestCase): + def setUp(self): + self.wty = parse('tests/fixtures/warranty_status.xml', 'warrantyDetailInfo') + + def test_purchase_date(self): + self.assertIsInstance(self.wty.estimatedPurchaseDate.pyval, date) + + def test_config_description(self): + self.assertEqual(self.wty.configDescription, 'IPHONE 4,16GB BLACK') + + +if __name__ == '__main__': + unittest.main() |