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
=== modified file 'src/scopes/ebay.py'
--- src/scopes/ebay.py 2016-05-30 12:22:13 +0000
+++ src/scopes/ebay.py 2016-06-07 14:28:03 +0000
@@ -167,9 +167,9 @@
167 res['image_hint'] = res['icon_hint']167 res['image_hint'] = res['icon_hint']
168 res['title'] = item['title'][0]168 res['title'] = item['title'][0]
169 res['uri'] = item['viewItemURL'][0]169 res['uri'] = item['viewItemURL'][0]
170 if 'condition' in item:170 try:
171 res['condition'] = item['condition'][0]['conditionDisplayName'][0]171 res['condition'] = item['condition'][0]['conditionDisplayName'][0]
172 else:172 except KeyError:
173 res['condition'] = None173 res['condition'] = None
174 res['shipping_to'] = ', '.join(item[174 res['shipping_to'] = ', '.join(item[
175 'shippingInfo'][0]['shipToLocations'])175 'shippingInfo'][0]['shipToLocations'])
176176
=== added file 'src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json'
--- src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json 1970-01-01 00:00:00 +0000
+++ src/scopes/tests/fixtures/ebay-searcheditem-nocondition.json 2016-06-07 14:28:03 +0000
@@ -0,0 +1,1 @@
1{"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"]}]}
02
=== modified file 'src/scopes/tests/test_ebay.py'
--- src/scopes/tests/test_ebay.py 2016-05-30 12:22:13 +0000
+++ src/scopes/tests/test_ebay.py 2016-06-07 14:28:03 +0000
@@ -826,3 +826,8 @@
826 item = json.loads(get_fixture('ebay-searcheditem-nopayment.json'))826 item = json.loads(get_fixture('ebay-searcheditem-nopayment.json'))
827 resp = ebay._parse_searched_item(item, 'en')827 resp = ebay._parse_searched_item(item, 'en')
828 self.assertEqual(resp['payment_method'], None)828 self.assertEqual(resp['payment_method'], None)
829
830 def test_searched_no_condition(self):
831 item = json.loads(get_fixture('ebay-searcheditem-nocondition.json'))
832 resp = ebay._parse_searched_item(item, 'en')
833 self.assertEqual(resp['condition'], None)

Subscribers

People subscribed via source and target branches