Skip to content

Commit

Permalink
feat(override-plan): Ability to fetch a single subscription (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsempe authored Oct 5, 2023
1 parent 1fbd78a commit c9d0efe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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 @@ -114,6 +114,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

0 comments on commit c9d0efe

Please sign in to comment.