Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed error when getting instance_url from resources without id #10

Merged
merged 3 commits into from
Mar 2, 2017

Conversation

hirokiky
Copy link
Contributor

@hirokiky hirokiky commented Mar 2, 2017

Creating resource without id and getting instance_url will raise TypeError

Traceback (most recent call last):
  File "/Users/user1/dev/payjp-python/payjp/test/test_resources.py", line 201, in test_instance_url_without_id
    resource.instance_url()
  File "/Users/user1/dev/payjp-python/payjp/resource.py", line 259, in instance_url
    raise error.InvalidRequestError
TypeError: __init__() takes at least 3 arguments (1 given)

I added a test to detect it and fixed.

Cases

I think this case is not rare.
Because it will happen on calling retrieve with None.

subscription = ...  # Creating local object
subscription.payjp_id = None  # and it has `id` on payjp as optional (like Null-able field on Django model)

import payjp
payjp.Subscription.retrieve(subscription.payjp_id)  # raise TypeError

@wozozo wozozo merged commit b823511 into payjp:master Mar 2, 2017
@wozozo
Copy link
Contributor

wozozo commented Mar 2, 2017

🙇‍♀️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants