diff options
author | Filipp Lepalaan <filipp@mac.com> | 2014-03-07 11:16:21 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2014-03-07 11:16:21 +0200 |
commit | 79e4628a53f1cac06f6426b301dafa1351412702 (patch) | |
tree | ae04368811a29f30b1d8b9298abcfcd2cd471fbf | |
parent | 187735f29c43e5356b8d153f7db82e05d2440d60 (diff) | |
download | py-gsxws-79e4628a53f1cac06f6426b301dafa1351412702.tar.gz py-gsxws-79e4628a53f1cac06f6426b301dafa1351412702.tar.bz2 py-gsxws-79e4628a53f1cac06f6426b301dafa1351412702.zip |
Added timestamp datatype, more tests
-rw-r--r-- | gsxws/objectify.py | 7 | ||||
-rw-r--r-- | gsxws/products.py | 4 | ||||
-rw-r--r-- | tests/fixtures/escalation_details_lookup.xml | 29 | ||||
-rw-r--r-- | tests/test_gsxws.py | 21 |
4 files changed, 57 insertions, 4 deletions
diff --git a/gsxws/objectify.py b/gsxws/objectify.py index 3480b70..b37379c 100644 --- a/gsxws/objectify.py +++ b/gsxws/objectify.py @@ -84,7 +84,8 @@ def gsx_datetime(value): def gsx_timestamp(value): - return datetime.strptime(value, "%d-%b-%y %H:%M:%S") + # 03/06/14 09:01 PM + return datetime.strptime(value, "%m/%d/%y %H:%M %p") class GsxElement(objectify.ObjectifiedElement): @@ -126,6 +127,8 @@ class GsxElement(objectify.ObjectifiedElement): return gsx_price(result) if name.endswith('Date'): return gsx_date(result) + if name.endswith('Timestamp'): + return gsx_timestamp(result) if re.search(r'^[YN]$', result): return gsx_boolean(result) @@ -153,8 +156,10 @@ def parse(root, response): return root.find('*//%s' % response) + if __name__ == '__main__': import doctest import logging logging.basicConfig(level=logging.DEBUG) doctest.testmod() + diff --git a/gsxws/products.py b/gsxws/products.py index a9073d6..5b58a23 100644 --- a/gsxws/products.py +++ b/gsxws/products.py @@ -81,7 +81,7 @@ class Product(object): if date_received: self._gsx.unitReceivedDate = date_received - + self._gsx._submit("unitDetail", "WarrantyStatus", "warrantyDetailInfo") self.warrantyDetails = self._gsx._req.objects self.imageURL = self.warrantyDetails.imageURL @@ -186,7 +186,7 @@ class Product(object): @property def is_valid(self): - return self.is_iphone or self.is_ipad or self.is_mac + return self.is_ios or self.is_mac @property def has_warranty(self): diff --git a/tests/fixtures/escalation_details_lookup.xml b/tests/fixtures/escalation_details_lookup.xml new file mode 100644 index 0000000..6aa9335 --- /dev/null +++ b/tests/fixtures/escalation_details_lookup.xml @@ -0,0 +1,29 @@ +<?xml version='1.0' encoding='UTF-8'?> +<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> + <S:Body> + <ns3:GeneralEscalationDetailsLookupResponse xmlns:ns2="http://asp.core.endpoint.ws.gsx.ist.apple.com/" xmlns:ns3="http://gsxws.apple.com/elements/core/asp" xmlns:ns4="http://gsxws.apple.com/elements/global" xmlns:ns5="http://gsxws.apple.com/elements/core/asp/emea" xmlns:ns6="http://gsxws.apple.com/elements/core"> + <GeneralEscalationDetailsLookupResponse> + <operationId>4ClHBDHhOL0NWdQMp4XBB</operationId> + <lookupResponseData> + <escalationId>2392767</escalationId> + <escalationType>GSX Help</escalationType> + <escalationStatus>O</escalationStatus> + <issueType>GSX Usage Question</issueType> + <escalationTo>Apple</escalationTo> + <createdBy>filipp Lepalaan</createdBy> + <createTimestamp>03/06/14 09:01 PM</createTimestamp> + <lastViewedBy>filipp Lepalaan</lastViewedBy> + <lastViewedTimestamp>03/06/14 09:06 PM</lastViewedTimestamp> + <lastModifiedBy>filipp Lepalaan</lastModifiedBy> + <lastModifiedTimestamp>03/06/14 09:02 PM</lastModifiedTimestamp> + <escalationAge>4 minutes </escalationAge> + <escalationNotes> + <note>blaa</note> + <note>test +</note> + </escalationNotes> + </lookupResponseData> + </GeneralEscalationDetailsLookupResponse> + </ns3:GeneralEscalationDetailsLookupResponse> + </S:Body> +</S:Envelope>
\ No newline at end of file diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index 3cb1e06..5571c22 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- import logging -from datetime import date from os import environ as env +from datetime import date, datetime from unittest import main, skip, TestCase @@ -29,6 +29,24 @@ class TestCoreFunctions(TestCase): self.assertRegexpMatches(rep.dumps(), '<GsxObject><blaa>ääöö</blaa><orderLines>') +class TestTypes(TestCase): + def setUp(self): + xml = open('tests/fixtures/escalation_details_lookup.xml', 'r').read() + self.data = parse(xml, 'lookupResponseData') + + def test_unicode(self): + self.assertIsInstance(self.data.lastModifiedBy, unicode) + + def test_timestamp(self): + self.assertIsInstance(self.data.createTimestamp, datetime) + + def test_ts_comp(self): + self.assertGreater(datetime.now(), self.data.createTimestamp) + + def test_list(self): + self.assertIsInstance(self.data.escalationNotes, list) + + class TestErrorFunctions(TestCase): def setUp(self): xml = open('tests/fixtures/multierror.xml', 'r').read() @@ -251,6 +269,7 @@ class TestRepairUpdate(RemoteTestCase): result = self.repair.set_techid('XXXXX') self.assertEqual(result.confirmationNumber, self.dispatchId) + class TestCarryinRepairDetail(TestCase): def setUp(self): self.data = parse('tests/fixtures/repair_details_ca.xml', |