A fork of https://github.com/Synerty/SOAPpy-py3 This is a working tree till fixes get imported upstream.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

76 lines
1.6 KiB

  1. """
  2. Check handing of unicode.
  3. """
  4. import sys
  5. sys.path.insert(1, "..")
  6. from SOAPpy import *
  7. # Uncomment to see outgoing HTTP headers and SOAP and incoming
  8. #Config.debug = 1
  9. #Config.dumpHeadersIn = 1
  10. #Config.dumpSOAPIn = 1
  11. #Config.dumpSOAPOut = 1
  12. # ask for returned SOAP responses to be converted to basic python types
  13. Config.simplify_objects = 1
  14. #Config.BuildWithNoType = 1
  15. #Config.BuildWithNoNamespacePrefix = 1
  16. def headers():
  17. '''Return a soap header containing all the needed information.'''
  18. hd = Types.headerType()
  19. hd.useragent = Types.stringType("foo")
  20. return hd
  21. server = SOAPProxy("http://localhost:9900/",header=headers())
  22. adgroupid = 197497504
  23. keyword1 = { 'status': 'Moderate',
  24. 'adGroupId': 197497504,
  25. 'destinationURL': None,
  26. 'language': '',
  27. 'text': 'does not work',
  28. 'negative': bool(0),
  29. 'maxCpc': 50000,
  30. 'type': 'Keyword',
  31. 'id': 1 }
  32. keyword2 = { 'status': 'Moderate',
  33. 'adGroupId': 197497504,
  34. 'destinationURL': None,
  35. 'language': '',
  36. 'text': 'yes it does not',
  37. 'negative': bool(0),
  38. 'maxCpc': 50000,
  39. 'type': 'Keyword',
  40. 'id': 2 }
  41. keylist = [keyword1, keyword2]
  42. # Check that the data goes through properly
  43. retval = server.echo_simple(adgroupid, keylist)
  44. kw1 = retval[1][0]
  45. kw2 = retval[1][1]
  46. assert(retval[0] == adgroupid)
  47. for key in kw1.keys():
  48. assert(kw1[key]==keyword1[key])
  49. for key in kw2.keys():
  50. assert(kw2[key]==keyword2[key])
  51. # Check that the header is preserved
  52. retval = server.echo_header((adgroupid, keylist))
  53. assert(retval[1].has_key('useragent'))
  54. assert(retval[1]['useragent'] == 'foo')
  55. server.quit()
  56. print "Success!"