aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gsxws/core.py20
-rw-r--r--tests/test_gsxws.py4
2 files changed, 12 insertions, 12 deletions
diff --git a/gsxws/core.py b/gsxws/core.py
index 61ef0d7..8fba5b5 100644
--- a/gsxws/core.py
+++ b/gsxws/core.py
@@ -39,6 +39,8 @@ import xml.etree.ElementTree as ET
from datetime import date, time, datetime, timedelta
+VERSION = "0.9"
+
GSX_ENV = "it"
GSX_LANG = "en"
GSX_REGION = "emea"
@@ -262,7 +264,7 @@ class GsxRequest(object):
ws = httplib.HTTPSConnection(parsed.netloc, timeout=GSX_TIMEOUT)
ws.putrequest("POST", parsed.path)
- ws.putheader("User-Agent", "py-gsxws 0.9")
+ ws.putheader("User-Agent", "py-gsxws %s" % VERSION)
ws.putheader("Content-type", 'text/xml; charset="UTF-8"')
ws.putheader("Content-length", "%d" % len(xmldata))
ws.putheader("SOAPAction", '"%s"' % method)
@@ -305,9 +307,12 @@ class GsxRequest(object):
self.objects = objectify.parse(xml, response)
return self.objects
- def __str__(self):
+ def __unicode__(self):
return ET.tostring(self.env)
+ def __str__(self):
+ return unicode(self).encode('utf-8')
+
class GsxObject(object):
"XML/SOAP representation of a GSX object"
@@ -390,14 +395,9 @@ class GsxObject(object):
return root
- def __unicode__(self):
- #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')
+ def dumps(self):
+ req = GsxRequest(**{'GsxObject': self})
+ return ET.tostring(req.data, encoding='utf-8')
class GsxRequestObject(GsxObject):
diff --git a/tests/test_gsxws.py b/tests/test_gsxws.py
index af6d3bc..868a853 100644
--- a/tests/test_gsxws.py
+++ b/tests/test_gsxws.py
@@ -22,11 +22,11 @@ class RemoteTestCase(TestCase):
class TestCoreFunctions(TestCase):
def test_dump(self):
- rep = repairs.Repair(blaa='test')
+ rep = repairs.Repair(blaa=u'ääöö')
part = repairs.RepairOrderLine()
part.partNumber = '661-5571'
rep.orderLines = [part]
- self.assertRegexpMatches(str(rep), '<root><blaa>test</blaa><orderLines>')
+ self.assertRegexpMatches(rep.dumps(), '<GsxObject><blaa>ääöö</blaa><orderLines>')
class TestErrorFunctions(TestCase):