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

feat(override-plan): Ability to fetch a single subscription #196

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lago_python_client/subscriptions/clients.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from typing import ClassVar, Type

from ..base_client import BaseClient
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, UpdateCommandMixin
from ..mixins import CreateCommandMixin, DestroyCommandMixin, FindAllCommandMixin, FindCommandMixin, UpdateCommandMixin
from ..models.subscription import SubscriptionResponse


class SubscriptionClient(
CreateCommandMixin[SubscriptionResponse],
DestroyCommandMixin[SubscriptionResponse],
FindAllCommandMixin[SubscriptionResponse],
FindCommandMixin[SubscriptionResponse],
UpdateCommandMixin[SubscriptionResponse],
BaseClient,
):
Expand Down
19 changes: 19 additions & 0 deletions tests/test_subscription_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,25 @@ def test_invalid_destroy_subscription_request(httpx_mock: HTTPXMock):
with pytest.raises(LagoApiError):
client.subscriptions.destroy(identifier)

def test_valid_find_subscription_request(httpx_mock: HTTPXMock):
client = Client(api_key='886fe239-927d-4072-ab72-6dd345e8dd0d')
external_id = '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba'

httpx_mock.add_response(method='GET', url='https://api.getlago.com/api/v1/subscriptions/' + external_id, content=mock_response())
response = client.subscriptions.find(external_id)

assert response.lago_id == 'b7ab2926-1de8-4428-9bcd-779314ac129b'
assert response.external_customer_id == '5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba'


def test_invalid_find_subscription_request(httpx_mock: HTTPXMock):
client = Client(api_key='invalid')
external_id = 'invalid'

httpx_mock.add_response(method='GET', url='https://api.getlago.com/api/v1/subscriptions/' + external_id, status_code=404, content=b'')

with pytest.raises(LagoApiError):
client.subscriptions.find(external_id)

def test_valid_find_all_subscription_request_with_options(httpx_mock: HTTPXMock):
client = Client(api_key='886fe239-927d-4072-ab72-6dd345e8dd0d')
Expand Down