-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14910] Add e2e tests for some billing journals endpoints #172
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
Merged
albertsola
merged 1 commit into
main
from
MPT-14910-add-e-2-e-tests-for-billing-journals
Dec 29, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"externalIds": {"vendor": "ext-seeded-billing-sub-vendor-id", "invoice": "INV12345", "reference": "ORD-7924-7691-0805"}, "search": {"source": {"type": "Subscription", "criteria": "id", "value": "SUB-5839-4140-9574"},"order":{"criteria":"order.id","value":"ORD-7924-7691-0805"}, "item": {"criteria": "item.id", "value": "ITM-1767-7355-0001"}}, "period": {"start": "2025-12-22", "end": "2026-12-21"}, "price": {"unitPP": 10, "PPx1": 8.33}, "quantity": 10, "segment": "COM", "description": {"value1": "desc-1", "value2": "desc-2"}} | ||
robcsegal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import pathlib | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def billing_journal_fd(): | ||
| file_path = pathlib.Path("tests/data/test_billing_journal.jsonl").resolve() | ||
| fd = file_path.open("rb") | ||
| try: | ||
| yield fd | ||
| finally: | ||
| fd.close() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def billing_journal_id(e2e_config): | ||
| return e2e_config["billing.journal.id"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_billing_journal_id(): | ||
| return "BJO-0000-0000" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def billing_journal_factory(authorization_id): | ||
| def factory( | ||
| name: str = "E2E Created Billing Journal", | ||
| ): | ||
| return { | ||
| "authorization": {"id": authorization_id}, | ||
| "dueDate": "2026-01-02T19:00:00.000Z", | ||
| "externalIds": {}, | ||
| "name": name, | ||
| } | ||
|
|
||
| return factory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def created_billing_journal(async_mpt_vendor, billing_journal_factory): | ||
| new_billing_journal_request_data = billing_journal_factory( | ||
| name="E2E Created Billing Journal", | ||
| ) | ||
|
|
||
| created_billing_journal = await async_mpt_vendor.billing.journals.create( | ||
| new_billing_journal_request_data | ||
| ) | ||
|
|
||
| yield created_billing_journal | ||
|
|
||
| try: | ||
| await async_mpt_vendor.billing.journals.delete(created_billing_journal.id) | ||
| except MPTAPIError as error: | ||
| print(f"TEARDOWN - Unable to delete billing journal: {error.title}") # noqa: WPS421 | ||
robcsegal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def submitted_billing_journal(async_mpt_vendor, created_billing_journal, billing_journal_fd): | ||
| await async_mpt_vendor.billing.journals.submit(created_billing_journal.id) | ||
| await async_mpt_vendor.billing.journals.upload( | ||
| journal_id=created_billing_journal.id, | ||
| file=billing_journal_fd, | ||
| ) | ||
|
|
||
| return created_billing_journal | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def completed_billing_journal(async_mpt_vendor, submitted_billing_journal): | ||
| await async_mpt_vendor.billing.journals.accept(submitted_billing_journal.id) | ||
| await async_mpt_vendor.billing.journals.complete(submitted_billing_journal.id) | ||
| return submitted_billing_journal | ||
|
|
||
|
|
||
| async def test_get_billing_journal_by_id(async_mpt_vendor, billing_journal_id): | ||
| result = await async_mpt_vendor.billing.journals.get(billing_journal_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_list_billing_journals(async_mpt_vendor): | ||
| limit = 10 | ||
|
|
||
| result = await async_mpt_vendor.billing.journals.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| async def test_get_billing_journal_by_id_not_found(async_mpt_vendor, invalid_billing_journal_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_vendor.billing.journals.get(invalid_billing_journal_id) | ||
|
|
||
|
|
||
| async def test_filter_billing_journals(async_mpt_vendor, billing_journal_id): | ||
| select_fields = ["-value"] | ||
| filtered_billing_journals = ( | ||
| async_mpt_vendor.billing.journals.filter(RQLQuery(id=billing_journal_id)) | ||
| .filter(RQLQuery(name="E2E Seeded Billing Journal")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [billing_journal async for billing_journal in filtered_billing_journals.iterate()] | ||
|
|
||
| assert len(result) == 1 | ||
|
|
||
|
|
||
| def test_create_billing_journal(created_billing_journal): | ||
| result = created_billing_journal | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_update_billing_journal( | ||
| async_mpt_vendor, created_billing_journal, billing_journal_factory | ||
| ): | ||
| updated_name = "E2E Updated Billing Journal Name" | ||
| updated_billing_journal_data = billing_journal_factory(name=updated_name) | ||
|
|
||
| result = await async_mpt_vendor.billing.journals.update( | ||
| created_billing_journal.id, | ||
| updated_billing_journal_data, | ||
| ) | ||
|
|
||
| assert result.name == updated_name | ||
|
|
||
|
|
||
| async def test_delete_billing_journal(async_mpt_vendor, created_billing_journal): | ||
| result = created_billing_journal | ||
|
|
||
| await async_mpt_vendor.billing.journals.delete(result.id) | ||
|
|
||
|
|
||
| async def test_upload_billing_journal( | ||
| async_mpt_vendor, created_billing_journal, billing_journal_fd | ||
| ): | ||
| result = await async_mpt_vendor.billing.journals.upload( | ||
| journal_id=created_billing_journal.id, | ||
| file=billing_journal_fd, | ||
| ) | ||
|
|
||
| assert result is not None | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.