Merge lp:~facundo/ubuntu-rest-scopes/fix-ebay-noconditiondisplayname into lp:ubuntu-rest-scopes

Proposed by Facundo Batista
Status: Merged
Approved by: Roberto Alsina
Approved revision: 526
Merged at revision: 526
Proposed branch: lp:~facundo/ubuntu-rest-scopes/fix-ebay-noconditiondisplayname
Merge into: lp:ubuntu-rest-scopes
Diff against target: 34 lines (+8/-2)
3 files modified
src/scopes/ebay.py (+2/-2)
src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json (+1/-0)
src/scopes/tests/test_ebay.py (+5/-0)
To merge this branch: bzr merge lp:~facundo/ubuntu-rest-scopes/fix-ebay-noconditiondisplayname
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+296676@code.launchpad.net

Commit message

Support the case of no condition or condition not complete in the search response.

Description of the change

Support the case of no condition or condition not complete in the search response.Support the case of no condition or condition not complete in the search response.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/scopes/ebay.py'
2--- src/scopes/ebay.py 2016-05-30 12:22:13 +0000
3+++ src/scopes/ebay.py 2016-06-07 14:28:03 +0000
4@@ -167,9 +167,9 @@
5 res['image_hint'] = res['icon_hint']
6 res['title'] = item['title'][0]
7 res['uri'] = item['viewItemURL'][0]
8- if 'condition' in item:
9+ try:
10 res['condition'] = item['condition'][0]['conditionDisplayName'][0]
11- else:
12+ except KeyError:
13 res['condition'] = None
14 res['shipping_to'] = ', '.join(item[
15 'shippingInfo'][0]['shipToLocations'])
16
17=== added file 'src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json'
18--- src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json 1970-01-01 00:00:00 +0000
19+++ src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json 2016-06-07 14:28:03 +0000
20@@ -0,0 +1,1 @@
21+{"itemId": ["151395385200"], "topRatedListing": ["false"], "globalId": ["EBAY-GB"], "title": ["Conan the Swordsman (L Sprague de Camp, L Carter, B Nyberg, Paperback)"], "country": ["GB"], "condition": [{"conditionId": ["4000"]}], "pictureURLLarge": ["http://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/hKoAAOSwd4tT1oHb/$_1.JPG"], "galleryURL": ["http://thumbs1.ebaystatic.com/m/mWruVLT7AcyBb5Rmei3myZg/140.jpg"], "shippingInfo": [{"shippingType": ["Flat"], "shipToLocations": ["GB"], "shippingServiceCost": [{"@currencyId": "GBP", "__value__": "1.3"}]}], "autoPay": ["false"], "location": ["Stoke-on-Trent,United Kingdom"], "postalCode": ["ST78LP"], "primaryCategory": [{"categoryId": ["377"], "categoryName": ["Other Fiction"]}], "viewItemURL": ["http://www.ebay.co.uk/itm/Conan-Swordsman-L-Sprague-Camp-L-Carter-B-Nyberg-Paperback-/151395385200?pt=Fiction"], "sellingStatus": [{"currentPrice": [{"@currencyId": "GBP", "__value__": "0.99"}], "timeLeft": ["P2DT22H0M16S"], "convertedCurrentPrice": [{"@currencyId": "GBP", "__value__": "0.99"}], "bidCount": ["0"], "sellingState": ["Active"]}], "paymentMethod": ["PayPal"], "isMultiVariationListing": ["false"], "pictureURLSuperSize": ["http://i.ebayimg.com/00/s/MTIwMFgxNjAw/z/hKoAAOSwd4tT1oHb/$_3.JPG"], "listingInfo": [{"listingType": ["Auction"], "gift": ["false"], "bestOfferEnabled": ["false"], "startTime": ["2014-08-28T22:39:00.000Z"], "buyItNowAvailable": ["false"], "endTime": ["2014-09-04T10:38:55.000Z"]}]}
22
23=== modified file 'src/scopes/tests/test_ebay.py'
24--- src/scopes/tests/test_ebay.py 2016-05-30 12:22:13 +0000
25+++ src/scopes/tests/test_ebay.py 2016-06-07 14:28:03 +0000
26@@ -826,3 +826,8 @@
27 item = json.loads(get_fixture('ebay-searcheditem-nopayment.json'))
28 resp = ebay._parse_searched_item(item, 'en')
29 self.assertEqual(resp['payment_method'], None)
30+
31+ def test_searched_no_condition(self):
32+ item = json.loads(get_fixture('ebay-searcheditem-nocondition.json'))
33+ resp = ebay._parse_searched_item(item, 'en')
34+ self.assertEqual(resp['condition'], None)

Subscribers

People subscribed via source and target branches