Skip to content

Commit d91e374

Browse files
committed
pep8 fixes and added tests
1 parent bf47d4c commit d91e374

9 files changed

Lines changed: 105 additions & 26 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ ebaysdk.egg-info/
1313
\.tox
1414
venv/
1515
venv*
16+
\.virtualenvs

ebaysdk/parallel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
Licensed under CDDL 1.0
77
'''
88
import sys
9+
from ebaysdk.exception import ConnectionError
10+
import grequests
11+
912
if sys.version_info[0] >= 3:
1013
raise ImportError('grequests does not work with python3+')
1114

12-
import grequests
13-
from ebaysdk.exception import ConnectionError
14-
1515

1616
class Parallel(object):
1717
"""

ebaysdk/soa/__init__.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,6 @@ def load_from_app_config(self, app_config):
5555
def response_dict(self):
5656
return self.response.dict()
5757

58-
'''
59-
if self._response_dict:
60-
return self._response_dict
61-
62-
if self._response_content:
63-
64-
mydict = self.response.dict()
65-
66-
try:
67-
verb = self.verb + 'Response'
68-
self._response_dict = mydict['Envelope']['Body'][verb]
69-
70-
except KeyError:
71-
self._response_dict = mydict.get(self.verb + 'Response', mydict)
72-
73-
return self._response_dict
74-
'''
75-
7658
def build_request_headers(self, verb):
7759
return {
7860
'Content-Type': self.config.get('content_type'),

ebaysdk/trading/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ def _get_resp_body_errors(self):
785785
.format(eClass=eClass, severity=eSeverity, code=eCode, shortMsg=eShortMsg,
786786
longMsg=eLongMsg)
787787

788-
#from IPython import embed; embed()
788+
# from IPython import embed; embed()
789789

790790
if eSeverity == 'Warning':
791791
warnings.append(msg)

samples/trading.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ def verifyAddItemErrorCodes(opts):
189189
}
190190
}
191191

192+
motors_item = {
193+
'Item': {
194+
'Category': '101',
195+
'Title': 'My Title',
196+
'ItemCompatibilityList': {
197+
'Compatibility': [
198+
{
199+
'CompatibilityNotes': 'Fits for all trims and engines.',
200+
'NameValueList': [
201+
{'Name': 'Year', 'Value': '2001'},
202+
{'Name': 'Make', 'Value': 'Honda'},
203+
{'Name': 'Model', 'Value': 'Accord'}
204+
]
205+
},
206+
]
207+
}
208+
}
209+
}
210+
192211
api.execute('VerifyAddItem', myitem)
193212

194213
except ConnectionError as e:

tests/test_base.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
except ImportError:
3131
pass
3232

33-
os.environ.setdefault("EBAY_YAML", "ebay.yaml")
33+
# os.environ.setdefault("EBAY_YAML", "ebay.yaml")
3434

3535

3636
class TestBase(unittest.TestCase):
@@ -54,7 +54,13 @@ def test_run_doctest_connection(self):
5454
self.doctest(ebaysdk.connection)
5555

5656
def test_run_doctest_shopping(self):
57-
self.doctest(ebaysdk.shopping)
57+
s = ebaysdk.shopping.Connection(config_file=os.environ.get('EBAY_YAML'))
58+
resp = s.execute('GetCategoryInfo',
59+
{'CategoryID': '-1',
60+
'IncludeSelector': ['ChildCategories']})
61+
self.assertEqual(s.response.reply.Ack, 'Success')
62+
self.assertEqual(s.error(), None)
63+
#self.doctest(ebaysdk.shopping)
5864

5965
def test_run_doctest_trading(self):
6066
self.doctest(ebaysdk.trading)

tests/test_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
class TestErrors(unittest.TestCase):
1818

1919
def test_single_item(self):
20-
connection = ebaysdk.shopping.Connection(debug=True, version='799')
20+
connection = ebaysdk.shopping.Connection(version='799', config_file=os.environ.get('EBAY_YAML'))
2121

2222
for i in range(20):
2323
connection.execute('GetSingleItem', {

tests/test_request.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# -*- coding: utf-8 -*-
2+
3+
'''
4+
© 2012-2013 eBay Software Foundation
5+
Authored by: Tim Keefer
6+
Licensed under CDDL 1.0
7+
'''
8+
9+
from __future__ import absolute_import
10+
import os
11+
import unittest
12+
import re
13+
from ebaysdk.utils import dict2xml
14+
15+
os.environ.setdefault("EBAY_YAML", "ebay.yaml")
16+
17+
18+
class TestBase(unittest.TestCase):
19+
20+
def test_motors_compat_request_xml(self):
21+
motors_dict = {
22+
'Item': {
23+
'Category': '101',
24+
'Title': 'My Title',
25+
'ItemCompatibilityList': {
26+
'Compatibility': [
27+
{
28+
'CompatibilityNotes': 'Fits for all trims and engines.',
29+
'NameValueList': [
30+
{'Name': 'Year', 'Value': '2001'},
31+
{'Name': 'Make', 'Value': 'Honda'},
32+
{'Name': 'Model', 'Value': 'Accord'}
33+
]
34+
},
35+
]
36+
}
37+
}
38+
}
39+
40+
motors_xml = """<Item>
41+
<Category>101</Category>
42+
<ItemCompatibilityList>
43+
<Compatibility>
44+
<CompatibilityNotes>Fits for all trims and engines.</CompatibilityNotes>
45+
<NameValueList>
46+
<Name>Year</Name><Value>2001</Value>
47+
</NameValueList>
48+
<NameValueList>
49+
<Name>Make</Name><Value>Honda</Value>
50+
</NameValueList>
51+
<NameValueList>
52+
<Name>Model</Name><Value>Accord</Value>
53+
</NameValueList>
54+
</Compatibility>
55+
</ItemCompatibilityList>
56+
<Title>My Title</Title>
57+
</Item>
58+
"""
59+
60+
motors_xml = re.sub(r'>\s+<', '><', motors_xml)
61+
motors_xml = re.sub(r'\s+$', '', motors_xml)
62+
63+
self.assertEqual(dict2xml(motors_dict), motors_xml)
64+
65+
66+
if __name__ == '__main__':
67+
unittest.main()

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
envlist = py27,py36
33

44
[testenv]
5+
setenv =
6+
EBAY_YAML = ebay_private.yaml
7+
58
commands = pep8 --ignore=E202,E501 ebaysdk
6-
pylint -E ebaysdk
9+
pylint -E ebaysdk
10+
python setup.py test
711
whitelist_externals = make
812
deps = pep8
913
pylint

0 commit comments

Comments
 (0)