diff options
author | Filipp Lepalaan <f@230.to> | 2013-10-11 14:33:49 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-10-11 14:33:49 +0300 |
commit | 8d1c76e9a29a2bdf4a28afbd3945410a8c32bc6c (patch) | |
tree | 89427ee9d0205875a0be4c5c620efccc1c9c4dd5 | |
parent | afc39a635a2ee508bad3f4a79096ca66eb96969e (diff) | |
download | py-gsxws-8d1c76e9a29a2bdf4a28afbd3945410a8c32bc6c.tar.gz py-gsxws-8d1c76e9a29a2bdf4a28afbd3945410a8c32bc6c.tar.bz2 py-gsxws-8d1c76e9a29a2bdf4a28afbd3945410a8c32bc6c.zip |
Include data in GsxObject string rep.
-rw-r--r-- | gsxws/core.py | 9 | ||||
-rw-r--r-- | tests/test_gsxws.py | 7 |
2 files changed, 10 insertions, 6 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index b3c0d8b..61ef0d7 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -288,8 +288,7 @@ class GsxRequest(object): request.append(GSX_SESSION) if self._request == request_name: - "Some requests don't have a top-level container" - #self.data = list(self.data)[0] + # Some requests lack a top-level container request.extend(self.data) else: request.append(self.data) @@ -303,7 +302,6 @@ class GsxRequest(object): logging.debug("Response: %s %s %s" % (res.status, res.reason, xml)) response = response or self._response - #root = ET.fromstring(xml).find("*//%s" % response) self.objects = objectify.parse(xml, response) return self.objects @@ -393,7 +391,10 @@ class GsxObject(object): return root def __unicode__(self): - return ET.tostring(self.to_xml('root'), encoding='UTF-8') + #root = self.to_xml('root') + #root.append(self._data) + req = GsxRequest(**{'root': self}) + return ET.tostring(req.data, encoding='UTF-8') def __str__(self): return unicode(self).encode('utf-8') diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py index bee83b0..af6d3bc 100644 --- a/tests/test_gsxws.py +++ b/tests/test_gsxws.py @@ -22,8 +22,11 @@ class RemoteTestCase(TestCase): class TestCoreFunctions(TestCase): def test_dump(self): - r = repairs.Repair(blaa='test') - self.assertRegexpMatches(str(r), '<root><blaa>test</blaa></root>') + rep = repairs.Repair(blaa='test') + part = repairs.RepairOrderLine() + part.partNumber = '661-5571' + rep.orderLines = [part] + self.assertRegexpMatches(str(rep), '<root><blaa>test</blaa><orderLines>') class TestErrorFunctions(TestCase): |