Skip to content
This repository was archived by the owner on Jan 4, 2025. It is now read-only.

Requests via proxy and almost of InboundShipments requests#22

Merged
GriceTurrble merged 13 commits intopython-amazon-mws:developfrom
uns8t3d:master
Mar 10, 2018
Merged

Requests via proxy and almost of InboundShipments requests#22
GriceTurrble merged 13 commits intopython-amazon-mws:developfrom
uns8t3d:master

Conversation

@uns8t3d
Copy link
Copy Markdown
Contributor

@uns8t3d uns8t3d commented Jun 22, 2017

No description provided.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 23, 2017

Codecov Report

Merging #22 into develop will decrease coverage by 2.53%.
The diff coverage is 36.47%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #22      +/-   ##
===========================================
- Coverage    48.85%   46.31%   -2.54%     
===========================================
  Files            4        4              
  Lines          393      475      +82     
  Branches        22       27       +5     
===========================================
+ Hits           192      220      +28     
- Misses         192      245      +53     
- Partials         9       10       +1
Impacted Files Coverage Δ
mws/mws.py 48.17% <36.47%> (-3.81%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd5fd02...d83c2a9. Read the comment docs.

@uns8t3d
Copy link
Copy Markdown
Contributor Author

uns8t3d commented Jun 23, 2017

Can you please tell me what to do for passing codecov? Because I really don't know how to make tests for this

@jameshiew
Copy link
Copy Markdown
Contributor

Thanks for the PR! Don't worry about the code coverage, at the moment it is just for some parts of that have already had bugs with regards to py2/3 compatibility. To make tests for other parts of the code will be big work.

@uns8t3d
Copy link
Copy Markdown
Contributor Author

uns8t3d commented Jun 25, 2017

Ok, thanx for reply:)

@uns8t3d
Copy link
Copy Markdown
Contributor Author

uns8t3d commented Jul 1, 2017

So what will be with this pull request? Will it be merged?

@jameshiew
Copy link
Copy Markdown
Contributor

@Eyeless95 Yes definitely, will review it in the next week

mws/mws.py Outdated

def __init__(self, access_key, secret_key, account_id, region='US', domain='', uri="", version="", auth_token=""):
def __init__(self, access_key, secret_key, account_id, region='US', domain='', uri="", version="", auth_token="",
proxies=None):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing proxies is meant to be a protocolless URL like www.example.com ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is just the one URL, could we call this proxy and self.proxy instead of proxies ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, protocol is required, and I made http & https to avoid troubles with type of proxy, now this proxy settings works on my project, so this feature is tested for work

mws/mws.py Outdated
parsed_response.response = response
return parsed_response

def set_proxies(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to call this get_proxies or something similar, as we are not setting anything here on the instance, rather just making the dictionary and returning it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously I made this method because request didn't pass codecov :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'll add a note to the contribution docs saying not to worry about codecov (for now)

@jameshiew
Copy link
Copy Markdown
Contributor

@Eyeless95 am I good to make the minor naming changes mentioned? You said you're using it already, renaming proxies to proxy is the only thing that should affect your code that is already using it. Thanks again for the PR, it's much appreciated!

@uns8t3d
Copy link
Copy Markdown
Contributor Author

uns8t3d commented Jul 5, 2017

am I good to make the minor naming changes mentioned? - Sure, that's ok :)

@jameshiew
Copy link
Copy Markdown
Contributor

jameshiew commented Aug 4, 2017

Hey @Eyeless95, so over a month ago I said I would review the PR, how time flies 😄 ! I've set aside a day next week (Wednesday) to get everything for mws merged in. Thanks for your patience on this!

@uns8t3d
Copy link
Copy Markdown
Contributor Author

uns8t3d commented Aug 5, 2017

It is not a problem, I added few corrections to name of methods at this time, thanx for replying me:)

@jameshiew jameshiew changed the base branch from master to develop August 9, 2017 15:21
@jameshiew
Copy link
Copy Markdown
Contributor

Hey @Eyeless95, I made some small changes to the PR to do with the proxies functionality. The proxy stuff is good to merge in, if you are able to split it out into a separate PR that would be great, but otherwise no worries, I still need to test the inbound shipments a bit more then it can all be merged in at once. Though I am not sure I will be able to test all of the methods as the MWS account I am playing with does not use this functionality so much.

One thing you can maybe help with: I tried to use this method and got the following stack trace. InboundShipments is actually an InboundShipments instance instantiated with my MWS credentials.

>>> InboundShipments.get_inbound_guidance_for_sku(sku_list=('my_sku', ))
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    InboundShipments.get_inbound_guidance_for_sku(('my_sku', ))
  File "/Users/james/Desktop/mws/mws/mws.py", line 639, in get_inbound_guidance_for_sku
    return self.make_request(extra_data=data)
  File "/Users/james/Desktop/mws/mws/mws.py", line 200, in make_request
    request_description = '&'.join(['%s=%s' % (k, quote(params[k], safe='-_.~')) for k in sorted(params)])
  File "/Users/james/Desktop/mws/mws/mws.py", line 200, in <listcomp>
    request_description = '&'.join(['%s=%s' % (k, quote(params[k], safe='-_.~')) for k in sorted(params)])
  File "/Users/james/.pyenv/versions/3.6.1/lib/python3.6/urllib/parse.py", line 775, in quote
    return quote_from_bytes(string, safe)
  File "/Users/james/.pyenv/versions/3.6.1/lib/python3.6/urllib/parse.py", line 800, in quote_from_bytes
    raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

sku_list should be a list (or tuple) of SKUs right? I am not sure why it cannot build the request. Anyway I have not worked through everything yet so I might be missing something simple.

@GriceTurrble
Copy link
Copy Markdown
Member

GriceTurrble commented Nov 29, 2017

Hi folks,

I have some changes to the InboundShipments class that I built in my own fork of the original package (by czpython), including some calls that are missing in this PR. See here: https://github.com/GriceTurrble/python-amazon-mws/blob/master/mws/mws.py#L797

Note that my package is Python3 compatible, but not very backwards compatible to Py2.

I'd like to contribute changes such as the create_inbound_shipment request, but I don't want to complicate the process as it is currently. Please let me know where I can stick this code or otherwise assist.

Edit: just for clarity, I do not currently have an MWS account to play with, but I did previously work at a firm in which the main focus was creating and editing FBA shipments. Those methods are battle-tested, I assure you. :)

@GriceTurrble
Copy link
Copy Markdown
Member

@jameshiew In response to your stack trace, the sku_list will need to be passed through enumerate_param: it cannot be dropped straight onto the data dict as-is. Every parameter must end up as a single string in the end.

@jameshiew
Copy link
Copy Markdown
Contributor

Hey @GriceTurrble , I haven't been able to look at the repo lately as much I've wanted to, but feel free to make a PR or further help with this one, especially if your methods are battle tested! Thanks for the info about the stack trace, perhaps the enumerate_params is something the library should do. It may be some of the work can split out from this PR and integrated sooner (e.g. the proxy functionality @Eyeless95 has done), and then some other InboundShipments work from this PR and from your repo can be integrated later.

@GriceTurrble
Copy link
Copy Markdown
Member

Been a while, but I'm settled in the new job now and have some bandwidth to work on this. Will have a new PR specific to the InboundShipments section shortly. That will create some conflict with the work @Eyeless95 contributed already, and for that I apologize, but I feel that what I have is a bit more complete.

I'll continue on a separate PR when I'm ready to bring it in. Thanks.

Copy link
Copy Markdown
Member

@GriceTurrble GriceTurrble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#33 accepted recently with some of the same changes to FulfillmentInboundShipments. However, this PR covers some methods that 33 does not, and I'd like to merge them in.

Please commit the following changes so we can proceed:

  1. Update based on current state of the develop branch, taking changes to InboundShipments and Finances into effect.
  2. Remove method InboundShipments.get_service_status. This is overwriting the base MWS.get_service_status unnecessarily.
  3. The following methods are duplicate, and should be removed from this PR:
    • estimate_transport_request
    • get_bill_of_lading
    • get_package_labels
    • get_prep_instructions_for_asin
    • get_prep_instructions_for_sku
    • get_transport_content
    • list_inbound_shipment_items
    • list_inbound_shipment_items_by_next_token (covered by next_token_action decorator on list_inbound_shipment_items)
    • list_inbound_shipments
    • list_inbound_shipments_by_next_token (covered by next_token_action decorator on list_inbound_shipments)
    • void_transport_request
  4. The following methods are new, and should be included in this PR (leave in place):
    • confirm_preorder
    • confirm_transport_request
    • get_inbound_guidance_for_asin
    • get_inbound_guidance_for_sku
    • get_pallet_labels
    • get_preorder_info
    • get_unique_package_labels
    • put_transport_content
  5. Remove the change to version number in setup.py (we'll push that version up on our side shortly).
  6. Remove test_get_service_status_inbound (redundant coverage: see point 2 above)

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 10, 2018

Codecov Report

Merging #22 into develop will decrease coverage by 0.69%.
The diff coverage is 34.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop      #22     +/-   ##
==========================================
- Coverage    45.57%   44.88%   -0.7%     
==========================================
  Files            4        4             
  Lines          667      704     +37     
  Branches        66       70      +4     
==========================================
+ Hits           304      316     +12     
- Misses         348      374     +26     
+ Partials        15       14      -1
Impacted Files Coverage Δ
mws/mws.py 42.98% <34.21%> (-0.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9f62ac...8a3dd2c. Read the comment docs.

@GriceTurrble GriceTurrble dismissed their stale review March 10, 2018 18:56

Committed fixes that match my review notes.

@GriceTurrble GriceTurrble merged commit 94c7810 into python-amazon-mws:develop Mar 10, 2018
GriceTurrble pushed a commit that referenced this pull request Mar 10, 2018
GriceTurrble added a commit that referenced this pull request Mar 10, 2018
* Merge recent changes in master to develop branch (#45) (#47)

* Release for 0.8.0 (#42)

* Added Finances API Feature

* .setup.py: bump version to 0.7.5-dev0

* Split out request_description building from make_request()

So that it can be tested more easily, and refactored

* Split out building the initial params dict from make_request()

So that it can be tested more easily

* Add fake MWS credentials pytest fixture

* test_service_status() should use the pytest fake credentials fixture

* Add more pytest fixtures (access_key, secret_key, account_id, timestamp)

* Add test for calc_request_description()

* Split out calc_request_description() into more statements

So that it is easier to debug

* Fix calc_request_description - don't include leading ampersand

* Don't do automated deployments via Travis (for the moment)

* Update README.md badges

* InboundShipments, next_token_action decorator, and some style cleanups. (#33)

* Testing out git commits from VS Code

* Reverting the test commit

* Adding VS Code settings to gitignore.

* Style fixes

* MWS.enumerate_param deprecated: now using utils.enumerate_param and utils.enumerate_params

* InboundShipments fleshed out; added `utils.next_token_action` decorator; deprecated separate methods for `...by_next_token()`

* Bugfix, rename `_enumerate_param` to `enumerate_param` (no need for private)

* Fix for next_token issues.

* TravisCI flake8 complaining, fixes.

* Minor flake8 complaint.

* Hack to get flake8 to stop complaining.

* Strip pylint disables to clear line length issue.

* Correction to keyed params, now tests every item in values sequence to ensure all are dicts.

* Add tests for param methods in utils.

* Add test for next token decorator.

* Adding 'InboundShipments' to `__all__`

* Assigning response a default in __init__ for DictWrapper and DataWrapper

* Unneeded line breaks removed + docstring formatting

* Comment corrected. They're tuples, not sets.

* Finances methods updated to use next_token_action decorator

* Create .travis.yaml

* Update .gitignore

* Removing deploy code from local travis

* Delete .travis.yaml

* Pushed to 0.8.0-dev0

Recently added functionality to InboundShipments, as well as Finances API. These constitute feature additions with backwards compatibility, which calls for a minor version update.

* Adding Python 3.6 category

We are testing in 3.6 in Travis anyway. May as well include the note.

* Specified master and develop branches for badges

Ensured the badges for Travis and Codecov are pointing to the appropriate branches (used to be pointing to default, which was master in both cases).

* Updated comments throughout module

No substantial code changes, comment changes only. Also ensured all docstrings follow same format.

* Fixed docstring formatting

Also made slight update to docstring for ObjectDict to more clearly note what it does, vs what the original code did.

* Fix for flake8 (trailing whitespace)

* Fix for flake8 (trailing whitespace)

* Bump to 0.8.0 (drop dev tag) for release

* Bug: Incorrect use of `super` for back-compat

Using the old-style `super` syntax to comply with Python 2.7 compatibility. Not revealed in tests, because current tests don't touch the APIs. Whoops!

* Added back old object names in case needed

Old names `object_dict` and `xml2dict` added back in case the old objects are being used directly by some users.

To be removed in 1.0.0 release down the road.

* Version bump for agent string.

* Hi, howyadoin?

* Format request url with str.format

Remove old-style string formatting for sake of clarity.

* Refactor timestamp method.

* Naming cleanups

* Single-source package version for use in agent string.

* MWS refactored, split into different modules.

* Version bump for feature

* Move and incorporate new MerchantFulfillment API

* merge artifacts removed [broken]

* Methods from PR #22 added.

* Changes from PR #53 merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants