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

PLAT-480: Update Python Library to APIv2 #28

Merged
merged 4 commits into from
Jan 17, 2019
Merged

Conversation

phildini
Copy link
Contributor

@phildini phildini commented Jan 15, 2019

This PR does a first pass at APIv2 compatibility for the python client library.

All resource files, resource spec files, api files, and api spec files are now auto-generated.

Ran tests locally from python client repo; all passed.

platform darwin -- Python 3.6.1, pytest-3.3.2, py-1.5.2, pluggy-0.6.0
rootdir: /Users/philip/code/patreon-python, inifile: pytest.ini
plugins: cov-2.5.1
collected 65 items

patreon/api_spec.py ........................                                                                                                                                                                                                                                                                                                                         [ 36%]
patreon/oauth_spec.py ..                                                                                                                                                                                                                                                                                                                                             [ 40%]
patreon/jsonapi/parser_spec.py .............                                                                                                                                                                                                                                                                                                                         [ 60%]
patreon/jsonapi/url_util_spec.py ....                                                                                                                                                                                                                                                                                                                                [ 66%]
patreon/schemas/address_spec.py ..                                                                                                                                                                                                                                                                                                                                   [ 69%]
patreon/schemas/benefit_spec.py ..                                                                                                                                                                                                                                                                                                                                   [ 72%]
patreon/schemas/campaign_spec.py ..                                                                                                                                                                                                                                                                                                                                  [ 75%]
patreon/schemas/deliverable_spec.py ..                                                                                                                                                                                                                                                                                                                               [ 78%]
patreon/schemas/goal_spec.py ..                                                                                                                                                                                                                                                                                                                                      [ 81%]
patreon/schemas/media_spec.py .                                                                                                                                                                                                                                                                                                                                      [ 83%]
patreon/schemas/member_spec.py ..                                                                                                                                                                                                                                                                                                                                    [ 86%]
patreon/schemas/oauthclient_spec.py ..                                                                                                                                                                                                                                                                                                                               [ 89%]
patreon/schemas/tier_spec.py ..                                                                                                                                                                                                                                                                                                                                      [ 92%]
patreon/schemas/user_spec.py ..                                                                                                                                                                                                                                                                                                                                      [ 95%]
patreon/schemas/webhook_spec.py ..                                                                                                                                                                                                                                                                                                                                   [ 98%]
patreon/version_compatibility/utc_timezone_spec.py .                                                                                                                                                                                                                                                                                                                 [100%]

---------- coverage: platform darwin, python 3.6.1-final-0 -----------
Name                                                 Stmts   Miss  Cover
------------------------------------------------------------------------
patreon/__init__.py                                      2      0   100%
patreon/api.py                                          94      2    98%
patreon/api_spec.py                                    218     27    88%
patreon/jsonapi/__init__.py                              0      0   100%
patreon/jsonapi/parser.py                               67      4    94%
patreon/jsonapi/parser_spec.py                          70      0   100%
patreon/jsonapi/url_util.py                             15      0   100%
patreon/jsonapi/url_util_spec.py                        15      0   100%
patreon/oauth.py                                        14      0   100%
patreon/oauth_spec.py                                   17      0   100%
patreon/schemas/__init__.py                              0      0   100%
patreon/schemas/address.py                              13      0   100%
patreon/schemas/address_spec.py                         14      0   100%
patreon/schemas/benefit.py                              20      0   100%
patreon/schemas/benefit_spec.py                         14      0   100%
patreon/schemas/campaign.py                             31      0   100%
patreon/schemas/campaign_spec.py                        14      0   100%
patreon/schemas/deliverable.py                           9      0   100%
patreon/schemas/deliverable_spec.py                     14      0   100%
patreon/schemas/goal.py                                  9      0   100%
patreon/schemas/goal_spec.py                            14      0   100%
patreon/schemas/media.py                                14      0   100%
patreon/schemas/media_spec.py                           10      1    90%
patreon/schemas/member.py                               17      0   100%
patreon/schemas/member_spec.py                          14      0   100%
patreon/schemas/oauthclient.py                          17      0   100%
patreon/schemas/oauthclient_spec.py                     14      0   100%
patreon/schemas/tier.py                                 21      0   100%
patreon/schemas/tier_spec.py                            14      0   100%
patreon/schemas/user.py                                 19      0   100%
patreon/schemas/user_spec.py                            14      0   100%
patreon/schemas/webhook.py                              10      0   100%
patreon/schemas/webhook_spec.py                         14      0   100%
patreon/utils.py                                         4      0   100%
patreon/version_compatibility/__init__.py                0      0   100%
patreon/version_compatibility/utc_timezone.py           16     10    38%
patreon/version_compatibility/utc_timezone_spec.py       3      0   100%
------------------------------------------------------------------------
TOTAL                                                  865     44    95%

This PR does a first pass at APIv2 compatibility for the python client library.

All resource files and resource spec files are now auto-generated.
@phildini phildini added the WIP Work in Progress label Jan 15, 2019
@phildini phildini changed the title [WIP] PLAT-480: Update Python Library to APIv2 PLAT-480: Update Python Library to APIv2 Jan 15, 2019
@phildini phildini removed the WIP Work in Progress label Jan 15, 2019
@phildini phildini requested review from a team and 21echoes January 15, 2019 23:25
Copy link
Contributor

@21echoes 21echoes left a comment

Choose a reason for hiding this comment

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

one blocker, one potential issue. super excited to get v2 clients out the door!

patreon/api.py Outdated
if not includes:
includes = campaign.default_relationships \
+ [campaign.Relationships.pledges]
def fetch_campaigns(self, includes=None, fields=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a second definition of fetch_campaigns with the same signature, no?

)

def fetch_members(self, campaign_id, page_size, cursor=None, includes=None, fields=None):
url = url = 'campaigns/{0}/members'.format(campaign_id)
params = {'page[count]': page_size}
if cursor:
Copy link
Contributor

Choose a reason for hiding this comment

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

this code assumes cursor will be a datetime object -- is that still the case for paginating through members? https://docs.patreon.com/#get-api-oauth2-v2-campaigns-campaign_id-members implies it is not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we changed the cursor logic at all for APIv2, so we should be fine?

Copy link

@jrsun jrsun left a comment

Choose a reason for hiding this comment

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

looks great! just had one question.

]


def test_schema_attributes_are_properly_formatted(attributes):
Copy link

Choose a reason for hiding this comment

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

(question for my own edification) what calls these? what is attributes as passed in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for reminding me I need to update the README! But it's described in the README.

We could do much more with this in the future.

@phildini phildini merged commit 80c83f0 into master Jan 17, 2019
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.

3 participants