-
Notifications
You must be signed in to change notification settings - Fork 0
[MPT-14918] Added e2e tests for billing statements and statement charges #189
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
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 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
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
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,11 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def statement_charge_id(e2e_config): | ||
| return e2e_config["billing.statement.charge.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_statement_charge_id(): | ||
| return "CHG-0000-0000-0000-0000-0000" |
43 changes: 43 additions & 0 deletions
43
tests/e2e/billing/statement/charge/test_async_statement_charge.py
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,43 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def statement_charges(async_mpt_ops, statement_id): | ||
| return async_mpt_ops.billing.statements.charges(statement_id) | ||
|
|
||
|
|
||
| async def test_get_statement_charge_by_id(statement_charges, statement_charge_id): | ||
| result = await statement_charges.get(statement_charge_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_get_statement_charge_by_id_not_found(statement_charges, invalid_statement_charge_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await statement_charges.get(invalid_statement_charge_id) | ||
|
|
||
|
|
||
| async def test_list_statement_charges(statement_charges): | ||
| limit = 10 | ||
|
|
||
| result = await statement_charges.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| async def test_filter_statement_charges(statement_charges, statement_charge_id): | ||
| select_fields = ["-price"] | ||
| filtered_charges = ( | ||
| statement_charges.filter(RQLQuery(id=statement_charge_id)) | ||
| .filter(RQLQuery(externalIds__invoice="INV12345")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [statement async for statement in filtered_charges.iterate()] | ||
|
|
||
| assert len(result) == 1 |
43 changes: 43 additions & 0 deletions
43
tests/e2e/billing/statement/charge/test_sync_statement_charge.py
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,43 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def statement_charges(mpt_ops, statement_id): | ||
| return mpt_ops.billing.statements.charges(statement_id) | ||
|
|
||
|
|
||
| def test_get_statement_charge_by_id(statement_charges, statement_charge_id): | ||
| result = statement_charges.get(statement_charge_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_get_statement_charge_by_id_not_found(statement_charges, invalid_statement_charge_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| statement_charges.get(invalid_statement_charge_id) | ||
|
|
||
|
|
||
| def test_list_statement_charges(statement_charges): | ||
| limit = 10 | ||
|
|
||
| result = statement_charges.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| def test_filter_statement_charges(statement_charges, statement_charge_id): | ||
| select_fields = ["-price"] | ||
| filtered_charges = ( | ||
| statement_charges.filter(RQLQuery(id=statement_charge_id)) | ||
| .filter(RQLQuery(externalIds__invoice="INV12345")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = list(filtered_charges.iterate()) | ||
|
|
||
| assert len(result) == 1 | ||
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,11 @@ | ||
| import pytest | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def statement_id(e2e_config): | ||
| return e2e_config["billing.statement.id"] | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def invalid_statement_id(): | ||
| return "SOM-0000-0000-0000-0000" |
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,38 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| async def test_get_statement_by_id(async_mpt_ops, statement_id): | ||
| result = await async_mpt_ops.billing.statements.get(statement_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| async def test_list_statements(async_mpt_ops): | ||
| limit = 10 | ||
|
|
||
| result = await async_mpt_ops.billing.statements.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| async def test_get_statement_by_id_not_found(async_mpt_ops, invalid_statement_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| await async_mpt_ops.billing.statements.get(invalid_statement_id) | ||
|
|
||
|
|
||
| async def test_filter_statements(async_mpt_ops, statement_id): | ||
| select_fields = ["-client"] | ||
| filtered_statements = ( | ||
| async_mpt_ops.billing.statements.filter(RQLQuery(id=statement_id)) | ||
| .filter(RQLQuery(type="Debit")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = [statement async for statement in filtered_statements.iterate()] | ||
|
|
||
| assert len(result) == 1 |
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,38 @@ | ||
| import pytest | ||
|
|
||
| from mpt_api_client.exceptions import MPTAPIError | ||
| from mpt_api_client.rql.query_builder import RQLQuery | ||
|
|
||
| pytestmark = [pytest.mark.flaky] | ||
|
|
||
|
|
||
| def test_get_statement_by_id(mpt_ops, statement_id): | ||
| result = mpt_ops.billing.statements.get(statement_id) | ||
|
|
||
| assert result is not None | ||
|
|
||
|
|
||
| def test_list_statements(mpt_ops): | ||
| limit = 10 | ||
|
|
||
| result = mpt_ops.billing.statements.fetch_page(limit=limit) | ||
|
|
||
| assert len(result) > 0 | ||
|
|
||
|
|
||
| def test_get_statement_by_id_not_found(mpt_ops, invalid_statement_id): | ||
| with pytest.raises(MPTAPIError, match=r"404 Not Found"): | ||
| mpt_ops.billing.statements.get(invalid_statement_id) | ||
|
|
||
|
|
||
| def test_filter_statements(mpt_ops, statement_id): | ||
| select_fields = ["-client"] | ||
| filtered_statements = ( | ||
| mpt_ops.billing.statements.filter(RQLQuery(id=statement_id)) | ||
| .filter(RQLQuery(type="Debit")) | ||
| .select(*select_fields) | ||
| ) | ||
|
|
||
| result = list(filtered_statements.iterate()) | ||
|
|
||
| assert len(result) == 1 |
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.