-
Notifications
You must be signed in to change notification settings - Fork 328
/
Copy pathtest_request.py
67 lines (56 loc) · 1.85 KB
/
test_request.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
# -*- coding: utf-8 -*-
'''
Copyright 2012-2019 eBay Inc.
Authored by: Tim Keefer
Licensed under CDDL 1.0
'''
from __future__ import absolute_import
import os
import unittest
import re
from ebaysdk.utils import dict2xml
os.environ.setdefault("EBAY_YAML", "ebay.yaml")
class TestBase(unittest.TestCase):
def test_motors_compat_request_xml(self):
motors_dict = {
'Item': {
'Category': '101',
'Title': 'My Title',
'ItemCompatibilityList': {
'Compatibility': [
{
'CompatibilityNotes': 'Fits for all trims and engines.',
'NameValueList': [
{'Name': 'Year', 'Value': '2001'},
{'Name': 'Make', 'Value': 'Honda'},
{'Name': 'Model', 'Value': 'Accord'}
]
},
]
}
}
}
motors_xml = """<Item>
<Category>101</Category>
<ItemCompatibilityList>
<Compatibility>
<CompatibilityNotes>Fits for all trims and engines.</CompatibilityNotes>
<NameValueList>
<Name>Year</Name><Value>2001</Value>
</NameValueList>
<NameValueList>
<Name>Make</Name><Value>Honda</Value>
</NameValueList>
<NameValueList>
<Name>Model</Name><Value>Accord</Value>
</NameValueList>
</Compatibility>
</ItemCompatibilityList>
<Title>My Title</Title>
</Item>
"""
motors_xml = re.sub(r'>\s+<', '><', motors_xml)
motors_xml = re.sub(r'\s+$', '', motors_xml)
self.assertEqual(dict2xml(motors_dict), motors_xml)
if __name__ == '__main__':
unittest.main()