yoavaviram / python-amazon-simple-product-api

A simple Python wrapper for the Amazon.com Product Advertising API ⛺
Apache License 2.0
817 stars 212 forks source link

Added support for AternateVersions Response group #135

Open ThomasProctor opened 6 years ago

ThomasProctor commented 6 years ago

Adds support for another response group. Part of the long slog to add support for #60.

I modeled this on how we support the "Images" response group. I'm not sure if it's the right way to do it, but I figured I should be consistent with the current API.

Here's some example usage:

In [11]: lookup_result = amazon.lookup(ItemId="1491914254", ResponseGroup='AlternateVersions')

In [12]: lookup_result.alternate_versions
Out[12]: 
[{'asin': '9352136047',
  'binding': 'Paperback',
  'title': "Deep Learning: A Practitioner's Approach"},
 {'asin': 'B074D5YF1D',
  'binding': 'Kindle Edition',
  'title': "Deep Learning: A Practitioner's Approach"}]
ThomasProctor commented 6 years ago

Some tests fail, as it looks like some of the info on products they query has changed. I opened an issue #134. All product-specific information should probably be removed from the tests. Instead, tests should just do type checks and check that the product information is present, and ignore what the specific value of that product information is.

ThomasProctor commented 6 years ago

Sorry about not opening a separate branch - I fixed an error in how browse_node_lookup handles invalid BrowseNodeIds. It turns out that the IsValid parameter does not, in fact, tell if the browse node id is valid. Instead, I had it check to see if any errors are made by the request. This was the bug highlighted by Issue #113.

Some pep8 white space changes in the test file got put in as well.