aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@230.to>2013-09-06 18:30:54 +0300
committerFilipp Lepalaan <f@230.to>2013-09-06 18:30:54 +0300
commit3f2fc53c57606a110162eccc2409f5bcc1172af0 (patch)
tree81306cfe0b028f49c0852742626da38fd83797d6
parentd3fc9cb6dfc89ea118038a5868b99e459cab911b (diff)
downloadpy-gsxws-3f2fc53c57606a110162eccc2409f5bcc1172af0.tar.gz
py-gsxws-3f2fc53c57606a110162eccc2409f5bcc1172af0.tar.bz2
py-gsxws-3f2fc53c57606a110162eccc2409f5bcc1172af0.zip
Added more coverage details to Product
-rw-r--r--gsxws/products.py26
-rw-r--r--tests/fixtures/onsite_coverage.xml38
-rw-r--r--tests/fixtures/repair_details_ca.xml5
-rw-r--r--tests/test_gsxws.py21
4 files changed, 87 insertions, 3 deletions
diff --git a/gsxws/products.py b/gsxws/products.py
index 654bef3..36aff3a 100644
--- a/gsxws/products.py
+++ b/gsxws/products.py
@@ -144,9 +144,35 @@ class Product(GsxObject):
import re
return ad.unlocked or (re.search("Unlock", ad.nextTetherPolicyDetails) is not None)
+ @property
+ def is_vintage(self):
+ title = self.warrantyDetails.productDescription
+ return title.startswith('~VIN,')
+
+ @property
def is_locked(self):
return not self.is_unlocked()
+ @property
+ def parts_covered(self):
+ return self.warrantyDetails.partCovered is True
+
+ @property
+ def labor_covered(self):
+ return self.warrantyDetails.laborCovered is True
+
+ @property
+ def parts_and_labor_covered(self):
+ return self.parts_covered and self.labor_covered
+
+ @property
+ def has_onsite(self):
+ from datetime import date
+ try:
+ return date.today() < self.warrantyDetails.onsiteEndDate
+ except Exception:
+ return False
+
if __name__ == '__main__':
import sys
diff --git a/tests/fixtures/onsite_coverage.xml b/tests/fixtures/onsite_coverage.xml
new file mode 100644
index 0000000..1fbb0ea
--- /dev/null
+++ b/tests/fixtures/onsite_coverage.xml
@@ -0,0 +1,38 @@
+<?xml version='1.0' encoding='utf-8'?>
+<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
+ <S:Body>
+ <ns3:WarrantyStatusResponse xmlns:ns2="http://asp.core.endpoint.ws.gsx.ist.apple.com/" xmlns:ns3="http://gsxws.apple.com/elements/global" xmlns:ns4="http://gsxws.apple.com/elements/core/asp" xmlns:ns5="http://gsxws.apple.com/elements/core/asp/emea" xmlns:ns6="http://gsxws.apple.com/elements/core">
+ <WarrantyStatusResponse>
+ <operationId>oWynXen8awwVyLGnvh8L8Je</operationId>
+ <warrantyDetailInfo>
+ <serialNumber>XXXXXXXXXXXXXXXXXX</serialNumber>
+ <warrantyStatus>Custom Bid Contracts</warrantyStatus>
+ <coverageEndDate>10/13/13</coverageEndDate>
+ <coverageStartDate>10/14/10</coverageStartDate>
+ <daysRemaining>38</daysRemaining>
+ <estimatedPurchaseDate>10/14/10</estimatedPurchaseDate>
+ <onsiteStartDate>10/14/10</onsiteStartDate>
+ <onsiteEndDate>10/13/13</onsiteEndDate>
+ <purchaseCountry>US</purchaseCountry>
+ <registrationDate>10/14/10</registrationDate>
+ <imageURL>http://service.info.apple.com/parts/service_parts/products/mbp13_mid10.jpg</imageURL>
+ <explodedViewURL>http://service.info.apple.com/parts/service_parts/ev/mbp13_mid10.ev.pdf</explodedViewURL>
+ <manualURL>http://download.info.apple.com/Apple_Support_Area/Misc/Service/servicemanuals/mbp13_mid09.pdf</manualURL>
+ <productDescription>MacBook Pro (13-inch, Mid 2010)</productDescription>
+ <configDescription>MBP 13.3/2.4/2X2GB/250/SD/GLSY</configDescription>
+ <slaGroupDescription>ONSITE ORANGE (2ND BUS DAY)</slaGroupDescription>
+ <ecorathFlag>Y</ecorathFlag>
+ <contractCoverageEndDate>10/13/13</contractCoverageEndDate>
+ <contractCoverageStartDate>10/14/10</contractCoverageStartDate>
+ <contractType>CC</contractType>
+ <laborCovered>Y</laborCovered>
+ <partCovered>Y</partCovered>
+ <warrantyReferenceNo>XXXXXXXXXX</warrantyReferenceNo>
+ <isPersonalized></isPersonalized>
+ <acPlusFlag></acPlusFlag>
+ </warrantyDetailInfo>
+ <communicationMessage></communicationMessage>
+ </WarrantyStatusResponse>
+ </ns3:WarrantyStatusResponse>
+ </S:Body>
+</S:Envelope>
diff --git a/tests/fixtures/repair_details_ca.xml b/tests/fixtures/repair_details_ca.xml
index 53c3b28..c3a6a57 100644
--- a/tests/fixtures/repair_details_ca.xml
+++ b/tests/fixtures/repair_details_ca.xml
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns6:RepairDetailsResponse xmlns:ns2="http://asp.core.endpoint.ws.gsx.ist.apple.com/" xmlns:ns3="http://gsxws.apple.com/elements/global" xmlns:ns4="http://gsxws.apple.com/elements/core/asp" xmlns:ns5="http://gsxws.apple.com/elements/core/asp/am" xmlns:ns6="http://gsxws.apple.com/elements/core">
@@ -29,8 +30,8 @@
<county>Madera</county>
<region>005</region>
<city>CUPERTINO</city>
- <firstName>Ääkköset</firstName>
- <lastName>Tässäkin</lastName>
+ <firstName>??kk?set</firstName>
+ <lastName>T?ss?kin</lastName>
<primaryPhone>999999999</primaryPhone>
</primaryAddress>
<partsInfo>
diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py
index ee1d943..467a573 100644
--- a/tests/test_gsxws.py
+++ b/tests/test_gsxws.py
@@ -6,6 +6,7 @@ from datetime import date
from unittest import main, skip, TestCase
from gsxws.objectify import parse
+from gsxws.products import Product
from gsxws import repairs, escalations
@@ -95,6 +96,25 @@ class TestWarrantyFunctions(TestCase):
self.assertTrue(self.data.partCovered)
+class TestOnsiteCoverage(TestCase):
+ def setUp(self):
+ from gsxws.core import connect
+ logging.basicConfig(level=logging.DEBUG)
+ env = os.environ
+ connect(env['GSX_USER'], env['GSX_PASSWORD'], env['GSX_SOLDTO'], env['GSX_ENV'])
+ self.product = Product('XXXXXXXXXXX')
+ self.product.warranty()
+
+ def test_has_onsite(self):
+ self.assertTrue(self.product.has_onsite)
+
+ def test_coverage(self):
+ self.assertTrue(self.product.parts_and_labor_covered)
+
+ def test_is_vintage(self):
+ self.assertFalse(self.product.is_vintage)
+
+
class TestActivation(TestCase):
def setUp(self):
self.data = parse('tests/fixtures/ios_activation.xml',
@@ -107,7 +127,6 @@ class TestActivation(TestCase):
self.assertIs(type(self.data.unlocked), bool)
self.assertTrue(self.data.unlocked)
- from gsxws.products import Product
p = Product()
self.assertTrue(p.is_unlocked(self.data))