This repository has been archived by the owner on Dec 28, 2024. It is now read-only.
forked from pelletier/SOAPpy
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathBug1001646.py
75 lines (56 loc) · 1.56 KB
/
Bug1001646.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Check handing of unicode.
"""
import sys
sys.path.insert(1, "..")
from SOAPpy import *
# Uncomment to see outgoing HTTP headers and SOAP and incoming
#Config.debug = 1
#Config.dumpHeadersIn = 1
#Config.dumpSOAPIn = 1
#Config.dumpSOAPOut = 1
# ask for returned SOAP responses to be converted to basic python types
Config.simplify_objects = 1
#Config.BuildWithNoType = 1
#Config.BuildWithNoNamespacePrefix = 1
def headers():
'''Return a soap header containing all the needed information.'''
hd = Types.headerType()
hd.useragent = Types.stringType("foo")
return hd
server = SOAPProxy("http://localhost:9900/",header=headers())
adgroupid = 197497504
keyword1 = { 'status': 'Moderate',
'adGroupId': 197497504,
'destinationURL': None,
'language': '',
'text': 'does not work',
'negative': bool(0),
'maxCpc': 50000,
'type': 'Keyword',
'id': 1 }
keyword2 = { 'status': 'Moderate',
'adGroupId': 197497504,
'destinationURL': None,
'language': '',
'text': 'yes it does not',
'negative': bool(0),
'maxCpc': 50000,
'type': 'Keyword',
'id': 2 }
keylist = [keyword1, keyword2]
# Check that the data goes through properly
retval = server.echo_simple(adgroupid, keylist)
kw1 = retval[1][0]
kw2 = retval[1][1]
assert(retval[0] == adgroupid)
for key in kw1.keys():
assert(kw1[key]==keyword1[key])
for key in kw2.keys():
assert(kw2[key]==keyword2[key])
# Check that the header is preserved
retval = server.echo_header((adgroupid, keylist))
assert(retval[1].has_key('useragent'))
assert(retval[1]['useragent'] == 'foo')
server.quit()
print "Success!"