diff --git a/chartmogul/__init__.py b/chartmogul/__init__.py index a76e1a2..f390ec7 100644 --- a/chartmogul/__init__.py +++ b/chartmogul/__init__.py @@ -33,7 +33,7 @@ Provides convenient Python bindings for ChartMogul's API. -:copyright: (c) 2019 by ChartMogul Ltd. +:copyright: (c) 2023 by ChartMogul Ltd. :license: MIT, see LICENSE for more details. """ @@ -41,4 +41,4 @@ __build__ = 0x000000 __author__ = 'ChartMogul Ltd' __license__ = 'MIT' -__copyright__ = 'Copyright 2021 ChartMogul Ltd' +__copyright__ = 'Copyright 2023 ChartMogul Ltd' diff --git a/chartmogul/api/subscription_event.py b/chartmogul/api/subscription_event.py index 256ea44..75e2455 100644 --- a/chartmogul/api/subscription_event.py +++ b/chartmogul/api/subscription_event.py @@ -5,7 +5,7 @@ class SubscriptionEvent(Resource): """ - https://dev.chartmogul.com/v1.0/reference#subscription_events + https://dev.chartmogul.com/reference/subscription-events """ _path = "/subscription_events" _root_key = 'subscription_events' @@ -16,8 +16,8 @@ class _Schema(Schema): data_source_uuid = fields.String(required=True) customer_external_id = fields.String(required=True) event_type = fields.String(required=True) - event_date = fields.Date(required=True) - effective_date = fields.Date(required=True) + event_date = fields.DateTime(required=True) + effective_date = fields.DateTime(required=True) subscription_external_id = fields.String(allow_none=True) plan_external_id = fields.String(allow_none=True) currency = fields.String(allow_none=True) diff --git a/chartmogul/version.py b/chartmogul/version.py index 726691b..f71b21a 100644 --- a/chartmogul/version.py +++ b/chartmogul/version.py @@ -1 +1 @@ -__version__ = '3.1.1' +__version__ = '3.1.2' diff --git a/fixtures/fetch_subscription_events.yaml b/fixtures/fetch_subscription_events.yaml new file mode 100644 index 0000000..bc1427d --- /dev/null +++ b/fixtures/fetch_subscription_events.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - chartmogul-python/3.1.2 + content-type: + - application/json + method: GET + uri: https://api.chartmogul.com/v1/subscription_events + response: + body: + string: !!binary | + H4sIAAAAAAAAA+2bXZOiOBSG/wvX7VS+P/wdfbVbUxRCUEGQhmDrdPV/3xC2dtepHRkJAbvKKm+U + Qzwkj29OXpOPoGk3TVzvK70/lqE6qVI3wfrPj2CfBGtMuUQCE/QSJJGOwubY1rEK27a7GCRNKDFM + oYzQKuZJuoJQJauNgnKVbjiPUkaTKJHBSxC3jT4Wqg7VWau6jA6hbYBDCTg0169yaJS+jivbw+Gn + mOt2ENn94Ni0Ux0i8wz//Y7+XvtYoXkEZdJGAOEVoCvIXwFbI7BG/A9zr0pTFev9Sf0cB/ArAGv7 + snFdF4X6UnVtXSUeR2WsDgeVdK39TxJ1faxN3358mg6plUkmCSP964Taqkv4dsxbG5V6ry/Bun/Q + uK1rVcb/vI+KY2uy3Zdh3A9sH6ajc/iLS7XSdRR339t3WjdQ3U2fL9dIQD9IQMEA64byqmfvRyLP + i0bwJxLdb28uJIAfJBCkEDB3JLIs3V2a8UiwR1MJm9CAStiYxVQCSz9IECoRBRMgQTWrd96QQLNP + HF8ACeEHCSgQ7/Tecd7Y/mDYRSTobZGYnwib0IBI2JjlRIL7IYIhTlBXfboiEVfbs0N1+USiW1H0 + hedvVpeY+UGCI8anmDc4T6pdNX7eII+mEjahAZWwMcupBPWDBKPUCIW7SuzqgorMGxLzr0G/ABLE + DxIQE47ciSCIxuVlPBH4tkjMT4RNaEAkbMxyIoH9EMEwR3gCV4LSfBN39tBIo+qJxP2lBPKEBAFi + CiSy8j19I+ORQI+mEjahAZWwMcuphCfvEhufindD6bjgIO8sSRxKiScS96uEJ++SAmjcS3ckUiYY + EuNVAj6aStiEBlTCxiymEsiTUcUwIXgCJHBxZmeHWmIAifmdqi+AhCdbgmEq4QROVYbzt62DSoDb + KjE/EjahAZWwMcuphCdbAgsMYDeUjrVE9l7k0sGpeiJxdy2BPNkS2FhVeILyMs0zWejRtQSUD6YS + fUK3VaKPWU4lPPkSxGzOYRMgIZDcvT+RMLuMZtstgZAfX4JALsQEuyVEqk+X8RMHFE+VuPdfL+TJ + l6AcCzGFSmRbpLt2xrmXQ0jMbmj3CQ1MHJbj5SYOj76EnOI/jktRoicSc04c0JMvATGXdIIVx1an + cZqNV4lH24wLbUIDKmFjFlMJ6GkHDSGSsAmQwLu3bONQSzyRuHsRCj2tOIyhjRkwv25HXyLfpCfq + oBKPthkX/sbOyz5mOZXwteKQUoAJ3Euc0wt2WIQOIDG7e/mQSHx/CQqlI3MKJSjNGZUwV+asyN/H + fKABpKrVqf+w37C3UemxVv0n/56cka8QralYQ/oNY2sRVtHWnIcxCxh91OZ4T/fWLH8I4p+ffwGd + 9Me3YzQAAA== + headers: + Access-Control-Allow-Credentials: + - 'true' + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Length: + - '1033' + Content-Type: + - application/json; charset=utf-8 + Date: + - Fri, 19 May 2023 12:58:15 GMT + ETag: + - W/"81eb5df6ece395240b6951a8223b5f5d" + Referrer-Policy: + - strict-origin-when-cross-origin + Vary: + - Accept-Encoding + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - DENY + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 7ac6e671676b1fe526cf0c67d988f7b1 + X-Runtime: + - '0.128295' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/requirements-test.txt b/requirements-test.txt index a0be1a2..1853eca 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -2,7 +2,7 @@ yarl mock>=1.0.1 requests-mock>=1.3.0 -vcrpy>=1.11.1 +vcrpy<3.0.0 PyYAML>=5.1.2 httpretty>=0.9.6 wrapt>=1.11.2 diff --git a/requirements.txt b/requirements.txt index 378c12d..e62d693 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ promise>=1.0.1 marshmallow>=3.10.0 future>=0.18.3 urllib3<2.0 +vcrpy<=4.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 319f0b6..3d7b9e9 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ 'promise>=1.0.1', 'marshmallow>=3.10.0', 'future>=0.18.3', + 'urllib3<2.0' ] test_requirements = [ # This is needed to circumvent a vcrpy dependency problem And can be @@ -28,7 +29,7 @@ 'mock>=1.0.1', 'requests-mock>=1.3.0', - 'vcrpy>=1.11.1', + 'vcrpy<3.0.0', 'PyYAML>=5.1.2', 'httpretty>=0.9.6', 'wrapt>=1.11.2' diff --git a/test/api/test_subscription_event.py b/test/api/test_subscription_event.py index 13c22c0..9fc80c1 100644 --- a/test/api/test_subscription_event.py +++ b/test/api/test_subscription_event.py @@ -15,8 +15,8 @@ "customer_external_id": "scus_022", "data_source_uuid": "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", "event_type": "subscription_start_scheduled", - "event_date": "2022-03-30", - "effective_date": "2022-04-01", + "event_date": "2022-03-30 23:00:00.000", + "effective_date": "2022-04-01 23:00:00.000", "subscription_external_id": "sub_0001", "plan_external_id": "gol d_monthly", "currency": "USD", @@ -31,8 +31,8 @@ "customer_external_id": "scus_022", "data_source_uuid": "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", "event_type": "subscription_start_scheduled", - "event_date": "2022-03-30", - "effective_date": "2022-04-01", + "event_date": "2022-03-30 23:00:00.000", + "effective_date": "2022-04-01 23:00:00.000", "subscription_external_id": "sub_0001", "plan_external_id": "gol d_monthly", "currency": "USD", @@ -54,8 +54,8 @@ customer_external_id="scus_022", data_source_uuid="ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", event_type="subscription_start_scheduled", - event_date="2022-03-30", - effective_date="2022-04-01", + event_date="2022-03-30 23:00:00.000", + effective_date="2022-04-01 23:00:00.000", subscription_external_id="sub_0001", plan_external_id="gol d_monthly", currency="USD", @@ -71,8 +71,8 @@ def test_create_subscription_event(self, mock_requests): "customer_external_id": "scus_022", "data_source_uuid": "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", "event_type": "subscription_start_scheduled", - "event_date": "2022-03-30", - "effective_date": "2022-04-01", + "event_date": "2022-03-30 23:00:00.000", + "effective_date": "2022-04-01 23:00:00.000", "subscription_external_id": "sub_0001", "plan_external_id": "gold_monthly", "currency": "USD", diff --git a/test/integration/fixtures/delete_invoice.yaml b/test/integration/fixtures/delete_invoice.yaml new file mode 100644 index 0000000..b1311e0 --- /dev/null +++ b/test/integration/fixtures/delete_invoice.yaml @@ -0,0 +1,34 @@ +interactions: +- request: + body: '{}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '2' + User-Agent: + - chartmogul-python/3.1.1 + content-type: + - application/json + method: POST + uri: https://api.chartmogul.com/v1/data_sources + response: + body: + string: '{"code":400,"message":"Parameter \"name\" is missing","param":"name"}' + headers: + Connection: + - keep-alive + Content-Length: + - '69' + Content-Type: + - application/json + Date: + - Fri, 19 May 2023 09:41:27 GMT + status: + code: 400 + message: Bad Request +version: 1 diff --git a/test/integration/fixtures/fetch_subscription_events.yaml b/test/integration/fixtures/fetch_subscription_events.yaml new file mode 100644 index 0000000..57e6f1c --- /dev/null +++ b/test/integration/fixtures/fetch_subscription_events.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - chartmogul-python/3.1.1 + content-type: + - application/json + method: GET + uri: https://api.chartmogul.com/v1/subscription_events + response: + body: + string: !!binary | + H4sIAAAAAAAAA+2b35KiOBTG34Xrdir/Q3yOvtqtKQohqCBIQ7B1uvrdNwlbu+vUjoyEgF1llTfK + IR6Sn19OPpOPoO02bdLsa7U/VpE8yUq1wfrPj2CfBmtMuUAhJuglSGMVR+2xaxIZdZ25GKRtJDDM + oIjRKuFptoJQpquNhGKVbTiPM0bTOBXBS5B0rTqWsonkWcmmig+RbYBDATjU169yaKW6jqu6w+Gn + mOt2ENn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RIfVZkb+P + +UANSN3IU/9hv2FvI7NjI/tP/j05I14hXgO8JvgbR9YPquOtPg+jFzDqqPTxHvNWL38I4p+ffwES + uS0yYzQAAA== + headers: + Access-Control-Allow-Credentials: + - 'true' + Cache-Control: + - max-age=0, private, must-revalidate + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Length: + - '1033' + Content-Type: + - application/json; charset=utf-8 + Date: + - Fri, 19 May 2023 13:03:43 GMT + ETag: + - W/"605f65f25551e36f294b1276648844b4" + Referrer-Policy: + - strict-origin-when-cross-origin + Vary: + - Accept-Encoding + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - DENY + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 4549e2f044e141372f3e09f1bf571314 + X-Runtime: + - '0.052033' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 1 diff --git a/test/integration/test_delete_invoice b/test/integration/test_delete_invoice deleted file mode 100644 index d6398a6..0000000 --- a/test/integration/test_delete_invoice +++ /dev/null @@ -1,24 +0,0 @@ -interactions: -- request: - body: !!python/unicode '{"name": "Test"}' - headers: - Accept: ['*/*'] - Accept-Encoding: ['gzip, deflate'] - Authorization: [Basic LTot] - Connection: [keep-alive] - Content-Length: ['16'] - User-Agent: [python-requests/2.13.0] - content-type: [application/json] - method: POST - uri: https://api.chartmogul.com/v1/data_sources - response: - body: {string: !!python/unicode '{"code":401,"message":"No valid API key provided","param":null}'} - headers: - connection: [keep-alive] - content-length: ['63'] - content-type: [application/json] - date: ['Wed, 21 Jun 2017 08:31:54 GMT'] - server: [nginx/1.10.1] - status: [401 Unauthorized] - status: {code: 401, message: Unauthorized} -version: 1 diff --git a/test/integration/test_fetch_subscription_events.py b/test/integration/test_fetch_subscription_events.py new file mode 100644 index 0000000..cac0b53 --- /dev/null +++ b/test/integration/test_fetch_subscription_events.py @@ -0,0 +1,13 @@ +import unittest +import vcr +from chartmogul import Config, SubscriptionEvent + +config = Config(api_key = '-') + +class FetchSubscriptionEventsTestCase(unittest.TestCase): + """ + Tests errors & user mistakes. + """ + @vcr.use_cassette('fixtures/fetch_subscription_events.yaml', filter_headers=['authorization']) + def test_subscription_events(self): + result = SubscriptionEvent.all(config).get() \ No newline at end of file