Skip to content

Commit 9db273b

Browse files
authored
[MPT-14918] Added e2e tests for billing statements and statement charges (#189)
Added e2e tests for billing statements and statement charges https://softwareone.atlassian.net/browse/MPT-14918 https://softwareone.atlassian.net/browse/MPT-14919 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> Closes [MPT-14918](https://softwareone.atlassian.net/browse/MPT-14918) - Added comprehensive end-to-end tests for billing statements, including retrieval, listing, filtering, and error handling for both synchronous and asynchronous operations - Added comprehensive end-to-end tests for billing statement charges, including retrieval, listing, and filtering for both synchronous and asynchronous operations - Added test configuration entries for billing statement and charge IDs to `e2e_config.test.json` - Added PyTest fixtures for statement IDs and charge IDs in separate conftest modules - Increased job timeout from 45 to 60 minutes across all GitHub Actions workflows (cron-main-e2e, pull-request, push-release-branch, and release) to accommodate longer test execution times <!-- end of auto-generated comment: release notes by coderabbit.ai --> [MPT-14918]: https://softwareone.atlassian.net/browse/MPT-14918?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
2 parents b2801fc + 4d35301 commit 9db273b

File tree

11 files changed

+190
-4
lines changed

11 files changed

+190
-4
lines changed

.github/workflows/cron-main-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
build:
88
runs-on: ubuntu-latest
9-
timeout-minutes: 45
9+
timeout-minutes: 60
1010
steps:
1111
- name: "Checkout"
1212
uses: actions/checkout@v6

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build:
1212

1313
runs-on: ubuntu-latest
14-
timeout-minutes: 45
14+
timeout-minutes: 60
1515

1616
steps:
1717
- name: "Checkout"

.github/workflows/push-release-branch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
16-
timeout-minutes: 45
16+
timeout-minutes: 60
1717

1818
steps:
1919
- name: "Checkout"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313

1414
runs-on: ubuntu-latest
15-
timeout-minutes: 45
15+
timeout-minutes: 60
1616

1717
steps:
1818
- name: "Checkout"

e2e_config.test.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
"billing.ledger.attachment.id": "LEA-4971-4321",
2222
"billing.ledger.charge.id": "CHG-2589-1434-0000-0000-0200",
2323
"billing.ledger.id": "BLE-2589-1434-7310-3075",
24+
"billing.statement.charge.id": "CHG-2589-1434-0000-0000-0200",
25+
"billing.statement.id": "SOM-7311-9982-9805-9250",
2426
"catalog.authorization.id": "AUT-9288-6146",
2527
"catalog.listing.id": "LST-5489-0806",
2628
"catalog.price_list.id": "PRC-7255-3950-0245",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def statement_charge_id(e2e_config):
6+
return e2e_config["billing.statement.charge.id"]
7+
8+
9+
@pytest.fixture
10+
def invalid_statement_charge_id():
11+
return "CHG-0000-0000-0000-0000-0000"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
from mpt_api_client.rql.query_builder import RQLQuery
5+
6+
pytestmark = [pytest.mark.flaky]
7+
8+
9+
@pytest.fixture
10+
def statement_charges(async_mpt_ops, statement_id):
11+
return async_mpt_ops.billing.statements.charges(statement_id)
12+
13+
14+
async def test_get_statement_charge_by_id(statement_charges, statement_charge_id):
15+
result = await statement_charges.get(statement_charge_id)
16+
17+
assert result is not None
18+
19+
20+
async def test_get_statement_charge_by_id_not_found(statement_charges, invalid_statement_charge_id):
21+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
22+
await statement_charges.get(invalid_statement_charge_id)
23+
24+
25+
async def test_list_statement_charges(statement_charges):
26+
limit = 10
27+
28+
result = await statement_charges.fetch_page(limit=limit)
29+
30+
assert len(result) > 0
31+
32+
33+
async def test_filter_statement_charges(statement_charges, statement_charge_id):
34+
select_fields = ["-price"]
35+
filtered_charges = (
36+
statement_charges.filter(RQLQuery(id=statement_charge_id))
37+
.filter(RQLQuery(externalIds__invoice="INV12345"))
38+
.select(*select_fields)
39+
)
40+
41+
result = [statement async for statement in filtered_charges.iterate()]
42+
43+
assert len(result) == 1
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
from mpt_api_client.rql.query_builder import RQLQuery
5+
6+
pytestmark = [pytest.mark.flaky]
7+
8+
9+
@pytest.fixture
10+
def statement_charges(mpt_ops, statement_id):
11+
return mpt_ops.billing.statements.charges(statement_id)
12+
13+
14+
def test_get_statement_charge_by_id(statement_charges, statement_charge_id):
15+
result = statement_charges.get(statement_charge_id)
16+
17+
assert result is not None
18+
19+
20+
def test_get_statement_charge_by_id_not_found(statement_charges, invalid_statement_charge_id):
21+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
22+
statement_charges.get(invalid_statement_charge_id)
23+
24+
25+
def test_list_statement_charges(statement_charges):
26+
limit = 10
27+
28+
result = statement_charges.fetch_page(limit=limit)
29+
30+
assert len(result) > 0
31+
32+
33+
def test_filter_statement_charges(statement_charges, statement_charge_id):
34+
select_fields = ["-price"]
35+
filtered_charges = (
36+
statement_charges.filter(RQLQuery(id=statement_charge_id))
37+
.filter(RQLQuery(externalIds__invoice="INV12345"))
38+
.select(*select_fields)
39+
)
40+
41+
result = list(filtered_charges.iterate())
42+
43+
assert len(result) == 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def statement_id(e2e_config):
6+
return e2e_config["billing.statement.id"]
7+
8+
9+
@pytest.fixture
10+
def invalid_statement_id():
11+
return "SOM-0000-0000-0000-0000"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import pytest
2+
3+
from mpt_api_client.exceptions import MPTAPIError
4+
from mpt_api_client.rql.query_builder import RQLQuery
5+
6+
pytestmark = [pytest.mark.flaky]
7+
8+
9+
async def test_get_statement_by_id(async_mpt_ops, statement_id):
10+
result = await async_mpt_ops.billing.statements.get(statement_id)
11+
12+
assert result is not None
13+
14+
15+
async def test_list_statements(async_mpt_ops):
16+
limit = 10
17+
18+
result = await async_mpt_ops.billing.statements.fetch_page(limit=limit)
19+
20+
assert len(result) > 0
21+
22+
23+
async def test_get_statement_by_id_not_found(async_mpt_ops, invalid_statement_id):
24+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
25+
await async_mpt_ops.billing.statements.get(invalid_statement_id)
26+
27+
28+
async def test_filter_statements(async_mpt_ops, statement_id):
29+
select_fields = ["-client"]
30+
filtered_statements = (
31+
async_mpt_ops.billing.statements.filter(RQLQuery(id=statement_id))
32+
.filter(RQLQuery(type="Debit"))
33+
.select(*select_fields)
34+
)
35+
36+
result = [statement async for statement in filtered_statements.iterate()]
37+
38+
assert len(result) == 1

0 commit comments

Comments
 (0)