aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2014-12-17 00:11:28 +0200
committerFilipp Lepalaan <filipp@mac.com>2014-12-17 00:11:28 +0200
commitc1d744de2e3f59a18bd0943f29911ccafba7c1b5 (patch)
treeff0da09399406d28974b3730f0a30f72a40078b9
parent5defed13830d1e3f164b7c4894bd228fcfabd33f (diff)
downloadpy-gsxws-0.5.tar.gz
py-gsxws-0.5.tar.bz2
py-gsxws-0.5.zip
CompTIA fixes0.5
-rw-r--r--gsxws/comptia.py14
-rw-r--r--gsxws/core.py10
-rw-r--r--tests/test_gsxws.py10
3 files changed, 24 insertions, 10 deletions
diff --git a/gsxws/comptia.py b/gsxws/comptia.py
index bdbc7d4..61164f8 100644
--- a/gsxws/comptia.py
+++ b/gsxws/comptia.py
@@ -11,6 +11,7 @@ MODIFIERS = (
("E", "Environmental"),
("F", "Configuration: Peripheral"),
("G", "Damaged"),
+ ("H", "Apple Review"),
)
GROUPS = (
@@ -28,6 +29,7 @@ GROUPS = (
('B', "iPhone"),
('E', "iPod"),
('F', "iPad"),
+ ('G', "Beats Products"),
)
@@ -57,23 +59,21 @@ class CompTIA(GsxObject):
>>> CompTIA().fetch() # doctest: +ELLIPSIS
{u'A': {'989': u'Remote Inoperable', ...
"""
- self._submit("ComptiaCodeLookupRequest", "ComptiaCodeLookup", "comptiaInfo", True)
+ if self._cache.get('comptia'):
+ return self._cache.get('comptia')
- if self._cache.get():
- return self._cache.get()
-
- root = self._req.objects
+ doc = self._submit("ComptiaCodeLookupRequest", "ComptiaCodeLookup", "comptiaInfo", raw=True)
+ root = doc.find('.//comptiaInfo')
for el in root.findall(".//comptiaGroup"):
group = {}
comp_id = unicode(el[0].text)
-
for ci in el.findall("comptiaCodeInfo"):
group[ci[0].text] = unicode(ci[1].text)
self._comptia[comp_id] = group
- self._cache.set(self._comptia)
+ self._cache.set('comptia', self._comptia)
return self._comptia
def symptoms(self, component=None):
diff --git a/gsxws/core.py b/gsxws/core.py
index e1e5a50..c2e26a4 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -226,8 +226,8 @@ class GsxCache(object):
def set(self, key, value):
d = {
- 'value': value,
- 'expires': self.now + self.expires
+ 'value' : value,
+ 'expires' : self.now + self.expires
}
self.shelf[key] = d
@@ -256,6 +256,7 @@ class GsxRequest(object):
ET.SubElement(self.env, "soapenv:Header")
self.body = ET.SubElement(self.env, "soapenv:Body")
+ self.xml_response = ''
for k, v in kwargs.items():
self.obj = v
@@ -309,11 +310,16 @@ class GsxRequest(object):
data = ET.tostring(self.env, "UTF-8")
res = self._send(method, data)
xml = res.read()
+ self.xml_response = xml
if res.status > 200:
raise GsxError(xml=xml, url=self._url)
logging.debug("Response: %s %s %s" % (res.status, res.reason, xml))
+
+ if raw:
+ return ET.fromstring(self.xml_response)
+
response = response or self._response
self.objects = objectify.parse(xml, response)
return self.objects
diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py
index 4192b09..0ca4c78 100644
--- a/tests/test_gsxws.py
+++ b/tests/test_gsxws.py
@@ -9,7 +9,7 @@ from unittest import main, skip, TestCase
from gsxws.objectify import parse, gsx_diags_timestamp
from gsxws.products import Product
from gsxws import (repairs, escalations, lookups,
- GsxError, ServicePart, diagnostics,)
+ GsxError, ServicePart, diagnostics, comptia,)
class RemoteTestCase(TestCase):
@@ -26,6 +26,14 @@ class RemoteTestCase(TestCase):
except AssertionError:
self.assertIsInstance(val, int)
+
+class ComptiaTestCase(RemoteTestCase):
+ def test_fetch_comptia(self):
+ data = comptia.CompTIA().fetch()
+ print data
+ self.assertIsInstance(data['E'], dict)
+
+
class DiagnosticsTestCase(RemoteTestCase):
def setUp(self):
super(DiagnosticsTestCase, self).setUp()