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

add support for cursor based pagination #85

Merged
merged 2 commits into from
Oct 2, 2023

Conversation

kmossco
Copy link
Contributor

@kmossco kmossco commented Oct 2, 2023

Changelog

Because this is being merged against a non main branch, GitHub workflows won't run but the local tests ran correctly:

Python 3.11.5
➜  chartmogul-python git:(support_cursor_pagination) coverage run ./setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
/opt/homebrew/lib/python3.11/site-packages/setuptools/command/test.py:193: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  ir_d = dist.fetch_build_eggs(dist.install_requires)
/opt/homebrew/lib/python3.11/site-packages/setuptools/command/test.py:194: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  tr_d = dist.fetch_build_eggs(dist.tests_require or [])
/opt/homebrew/lib/python3.11/site-packages/setuptools/command/test.py:195: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
!!

        ********************************************************************************
        Requirements should be satisfied by a PEP 517 installer.
        If you are using pip, you can try `pip install --use-pep517`.
        ********************************************************************************

!!
  er_d = dist.fetch_build_eggs(
running egg_info
writing chartmogul.egg-info/PKG-INFO
writing dependency_links to chartmogul.egg-info/dependency_links.txt
writing requirements to chartmogul.egg-info/requires.txt
writing top-level names to chartmogul.egg-info/top_level.txt
reading manifest file 'chartmogul.egg-info/SOURCES.txt'
adding license file 'LICENSE.txt'
writing manifest file 'chartmogul.egg-info/SOURCES.txt'
running build_ext
test_delete_invoice (test.integration.test_delete_invoice.DeleteInvoiceTestCase.test_delete_invoice) ... <function VCR._build_before_record_request.<locals>.before_record_request at 0x106988ea0>
Appending request <Request (POST) https://api.chartmogul.com/v1/data_sources> and response {'body': {'string': b'{"uuid":"ds_20b98cde-565d-11e7-953a-57e7aa662af2","name":"Test","system":"Import API","created_at":"2017-06-21T08:39:23.884Z","status":"idle"}'}, 'headers': {'access-control-allow-credentials': ['true'], 'connection': ['keep-alive'], 'content-length': ['142'], 'content-type': ['application/json'], 'date': ['Wed, 21 Jun 2017 08:39:23 GMT'], 'server': ['nginx/1.10.1'], 'status': ['201 Created']}, 'status': {'code': 201, 'message': 'Created'}}
Appending request <Request (POST) https://api.chartmogul.com/v1/customers> and response {'body': {'string': b'{"id":9232806,"uuid":"cus_20fdab30-565d-11e7-953a-c3eecbf6873c","external_id":"cus_0001","name":"Adam Smith","email":"adam@smith.com","status":"Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_20b98cde-565d-11e7-953a-57e7aa662af2","data_source_uuids":["ds_20b98cde-565d-11e7-953a-57e7aa662af2"],"external_ids":["cus_0001"],"company":"","country":"US","state":null,"city":"New York","zip":null,"lead_created_at":null,"free_trial_started_at":null,"address":{"country":"United States","state":null,"city":"New York","address_zip":null},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/9232806-Adam_Smith","billing-system-type":"Import API","currency":"USD","currency-sign":"$"}'}, 'headers': {'access-control-allow-credentials': ['true'], 'connection': ['keep-alive'], 'content-length': ['788'], 'content-type': ['application/json'], 'date': ['Wed, 21 Jun 2017 08:39:24 GMT'], 'server': ['nginx/1.10.1'], 'status': ['201 Created']}, 'status': {'code': 201, 'message': 'Created'}}
Appending request <Request (POST) https://api.chartmogul.com/v1/plans> and response {'body': {'string': b'{"external_id":"plan_0001","name":"Bronze Plan","interval_count":1,"interval_unit":"month","data_source_uuid":"ds_20b98cde-565d-11e7-953a-57e7aa662af2","uuid":"pl_21436c24-565d-11e7-99b5-c30bc3e995a3"}'}, 'headers': {'cache-control': ['max-age=0, private, must-revalidate'], 'connection': ['keep-alive'], 'content-type': ['application/json; charset=utf-8'], 'date': ['Wed, 21 Jun 2017 08:39:24 GMT'], 'etag': ['W/"7f595dd6f5144f7845844809661d0df5"'], 'server': ['nginx/1.10.1'], 'status': ['201 Created'], 'strict-transport-security': ['max-age=15768000'], 'x-content-type-options': ['nosniff'], 'x-frame-options': ['SAMEORIGIN'], 'x-request-id': ['05f1714e-1e39-4f93-b959-a49d0a450b0f'], 'x-runtime': ['0.079308'], 'x-xss-protection': ['1; mode=block']}, 'status': {'code': 201, 'message': 'Created'}}
Appending request <Request (POST) https://api.chartmogul.com/v1/import/customers/cus_20fdab30-565d-11e7-953a-c3eecbf6873c/invoices> and response {'body': {'string': b'{"invoices":[{"uuid":"inv_fb369587-7ed5-4049-9f02-8f6a8000499c","external_id":"INV0001","date":"2015-11-01T00:00:00.000Z","due_date":"2015-11-15T00:00:00.000Z","currency":"USD","line_items":[{"uuid":"li_1421544c-04bc-49f8-819c-8d37fe0bea9f","external_id":null,"type":"subscription","subscription_uuid":"sub_81a2a3b2-94f1-4858-94ea-852d9487acad","subscription_external_id":"sub_0001","plan_uuid":"pl_21436c24-565d-11e7-99b5-c30bc3e995a3","prorated":false,"service_period_start":"2015-11-01T00:00:00.000Z","service_period_end":"2015-12-01T00:00:00.000Z","amount_in_cents":5000,"quantity":1,"discount_code":"PSO86","discount_amount_in_cents":1000,"tax_amount_in_cents":900,"account_code":""}],"transactions":[{"uuid":"tr_a3d85ea1-7ae0-4a72-af28-3457993b3b4e","external_id":null,"type":"payment","date":"2015-11-05T00:14:23.000Z","result":"successful"}]}]}'}, 'headers': {'cache-control': ['max-age=0, private, must-revalidate'], 'connection': ['keep-alive'], 'content-type': ['application/json; charset=utf-8'], 'date': ['Wed, 21 Jun 2017 08:39:25 GMT'], 'etag': ['W/"22a408937b44a26f3ebe7e04fea0fe40"'], 'server': ['nginx/1.10.1'], 'strict-transport-security': ['max-age=15768000'], 'x-content-type-options': ['nosniff'], 'x-frame-options': ['SAMEORIGIN'], 'x-request-id': ['ea103d4e-ea0c-43b2-98b5-c67596b470db'], 'x-runtime': ['0.381086'], 'x-xss-protection': ['1; mode=block']}, 'status': {'code': 201, 'message': 'Created'}}
Appending request <Request (DELETE) https://api.chartmogul.com/v1/invoices/inv_fb369587-7ed5-4049-9f02-8f6a8000499c> and response {'body': {'string': b''}, 'headers': {'cache-control': ['no-cache'], 'connection': ['keep-alive'], 'date': ['Wed, 21 Jun 2017 08:39:25 GMT'], 'server': ['nginx/1.10.1'], 'strict-transport-security': ['max-age=15768000'], 'x-content-type-options': ['nosniff'], 'x-frame-options': ['SAMEORIGIN'], 'x-request-id': ['2cc5f524-46f3-4752-bd05-0c72893cc106'], 'x-runtime': ['0.148497'], 'x-xss-protection': ['1; mode=block']}, 'status': {'code': 204, 'message': 'No Content'}}
/Users/kmossco/code/chartmogul-python/chartmogul/retry_request.py:15: DeprecationWarning: Using 'method_whitelist' with Retry is deprecated and will be removed in v2.0. Use 'allowed_methods' instead
  retry = Retry(
Playing response for <Request (POST) https://api.chartmogul.com/v1/data_sources> from cassette
Playing response for <Request (POST) https://api.chartmogul.com/v1/customers> from cassette
Playing response for <Request (POST) https://api.chartmogul.com/v1/plans> from cassette
Playing response for <Request (POST) https://api.chartmogul.com/v1/import/customers/cus_20fdab30-565d-11e7-953a-c3eecbf6873c/invoices> from cassette
Playing response for <Request (DELETE) https://api.chartmogul.com/v1/invoices/inv_fb369587-7ed5-4049-9f02-8f6a8000499c> from cassette
None
ok
test_api_incorrect (test.api.test_common.CommonTestCase.test_api_incorrect) ... ok
test_date_serialization (test.api.test_common.CommonTestCase.test_date_serialization) ... ok
test_forget_uuid_destroy (test.api.test_common.CommonTestCase.test_forget_uuid_destroy) ... ok
test_forget_uuid_retrieve (test.api.test_common.CommonTestCase.test_forget_uuid_retrieve) ... ok
test_create_plan (test.api.test_plan.PlanTestCase.test_create_plan) ... ok
test_cursor_list_plans_new_pagination (test.api.test_plan.PlanTestCase.test_cursor_list_plans_new_pagination) ... ok
test_cursor_list_plans_old_pagination (test.api.test_plan.PlanTestCase.test_cursor_list_plans_old_pagination) ... ok
test_modify_plan (test.api.test_plan.PlanTestCase.test_modify_plan) ... ok
test_all (test.api.test_metrics.MetricsTestCase.test_all) ... ok
test_ltv (test.api.test_metrics.MetricsTestCase.test_ltv) ... ok
test_mrr_summary (test.api.test_metrics.MetricsTestCase.test_mrr_summary) ... ok
test_add (test.api.test_tags.TagsTestCase.test_add) ... ok
test_all (test.api.test_data_source.DataSourceTestCase.test_all) ... ok
test_create (test.api.test_data_source.DataSourceTestCase.test_create) ... ok
test_destroy (test.api.test_data_source.DataSourceTestCase.test_destroy) ... ok
test_retrieve (test.api.test_data_source.DataSourceTestCase.test_retrieve) ... ok
test_all_plan_groups_new_pagination (test.api.test_plan_group.PlanGroupTestCase.test_all_plan_groups_new_pagination) ... ok
test_all_plan_groups_old_pagination (test.api.test_plan_group.PlanGroupTestCase.test_all_plan_groups_old_pagination) ... ok
test_create_plan_group (test.api.test_plan_group.PlanGroupTestCase.test_create_plan_group) ... ok
test_destroy_plan_group (test.api.test_plan_group.PlanGroupTestCase.test_destroy_plan_group) ... ok
test_modify_plan_group_name (test.api.test_plan_group.PlanGroupTestCase.test_modify_plan_group_name) ... ok
test_modify_plan_group_plans (test.api.test_plan_group.PlanGroupTestCase.test_modify_plan_group_plans) ... ok
test_retrieve_plan_group (test.api.test_plan_group.PlanGroupTestCase.test_retrieve_plan_group) ... ok
test_retrieve_plan_group_plans_new_pagination (test.api.test_plan_group.PlanGroupTestCase.test_retrieve_plan_group_plans_new_pagination) ... ok
test_retrieve_plan_group_plans_old_pagination (test.api.test_plan_group.PlanGroupTestCase.test_retrieve_plan_group_plans_old_pagination) ... ok
test_all_new_pagination (test.api.test_customer.CustomerTestCase.test_all_new_pagination) ... ok
test_all_old_pagination (test.api.test_customer.CustomerTestCase.test_all_old_pagination) ... ok
test_connectSubscriptions (test.api.test_customer.CustomerTestCase.test_connectSubscriptions) ... ok
test_create (test.api.test_customer.CustomerTestCase.test_create) ... ok
test_merge (test.api.test_customer.CustomerTestCase.test_merge) ... ok
test_search_new_pagination (test.api.test_customer.CustomerTestCase.test_search_new_pagination) ... ok
test_search_old_pagination (test.api.test_customer.CustomerTestCase.test_search_old_pagination) ... ok
test_ping (test.api.test_ping.PingTestCase.test_ping) ... ok
test_add (test.api.test_custom_attrs.CustomAttributesTestCase.test_add) ... ok
test_add_to_email (test.api.test_custom_attrs.CustomAttributesTestCase.test_add_to_email) ... ok
test_create (test.api.test_invoice.InvoiceTestCase.test_create) ... ok
test_delete (test.api.test_invoice.InvoiceTestCase.test_delete) ... ok
test_delete_all (test.api.test_invoice.InvoiceTestCase.test_delete_all) ... ok
test_delete_not_found (test.api.test_invoice.InvoiceTestCase.test_delete_not_found) ... ok
test_list_has_customer_uuid (test.api.test_invoice.InvoiceTestCase.test_list_has_customer_uuid) ... ok
test_new_list_new_pagination (test.api.test_invoice.InvoiceTestCase.test_new_list_new_pagination) ... ok
test_new_list_old_pagination (test.api.test_invoice.InvoiceTestCase.test_new_list_old_pagination) ... ok
test_retrieve_invoice (test.api.test_invoice.InvoiceTestCase.test_retrieve_invoice) ... ok
test_requests_retry_session_on_resource (test.api.test_retry_request.RetryRequestTestCase.test_requests_retry_session_on_resource) ... captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=0)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=27)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=0)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=27)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=0)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=27)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=0)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=27)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=0)>
captured: <HTTPrettyRequest("POST", "https://api.chartmogul.com/v1/data_sources", headers={'Host': 'api.chartmogul.com', 'User-Agent': 'chartmogul-python/1.5.1', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'content-type': 'application/json', 'Content-Length': '27', 'Authorization': 'Basic dG9rZW46c2VjcmV0'}, body=27)>
ok
test_retry_request (test.api.test_retry_request.RetryRequestTestCase.test_retry_request) ... captured: <HTTPrettyRequest("GET", "https://example:444/testing", headers={'Host': 'example:444', 'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}, body=0)>
captured: <HTTPrettyRequest("GET", "https://example:444/testing", headers={'Host': 'example:444', 'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}, body=0)>
ok
test_cancel_subscription (test.api.test_subscription.SubscriptionsTestCase.test_cancel_subscription)
Test cancel (patch) subscription (cancelled_at). ... ok
test_list_imported_subscriptions_new_pagination (test.api.test_subscription.SubscriptionsTestCase.test_list_imported_subscriptions_new_pagination)
Test listing (get) subscriptions. ... ok
test_list_imported_subscriptions_old_pagination (test.api.test_subscription.SubscriptionsTestCase.test_list_imported_subscriptions_old_pagination)
Test listing (get) subscriptions. ... ok
test_modify_subscription (test.api.test_subscription.SubscriptionsTestCase.test_modify_subscription)
Test modify (patch) subscription (cancellation_dates). ... ok

----------------------------------------------------------------------
Ran 50 tests in 0.127s

OK

Signed-off-by: Bruno Vieira <bruno@chartmogul.com>
@kmossco kmossco self-assigned this Oct 2, 2023
@kmossco kmossco requested review from daesu and swember October 2, 2023 14:24
Signed-off-by: Bruno Vieira <bruno@chartmogul.com>
@kmossco kmossco merged commit 414067a into 1-5-stable Oct 2, 2023
@kmossco kmossco deleted the support_cursor_pagination branch October 2, 2023 15:09
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