Skip to content

Commit 92f8042

Browse files
author
Robert Segal
committed
added e2e tests for journal charges
1 parent 541ea30 commit 92f8042

File tree

6 files changed

+101
-3
lines changed

6 files changed

+101
-3
lines changed

e2e_config.test.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
"billing.custom_ledger.attachment.id": "CLA-1777-7485",
1616
"billing.custom_ledger.charge.id": "CHG-2665-3524-0000-0000-0020",
1717
"billing.custom_ledger.id": "CLE-2665-3524",
18-
"billing.journal.attachment.id": "JOA-6425-9776",
19-
"billing.journal.id": "BJO-6562-0928",
18+
"billing.journal.attachment.id": "JOA-2849-3620",
19+
"billing.journal.charge.id": "CHG-2589-1434-0000-0000-0200",
20+
"billing.journal.id": "BJO-2589-1434",
2021
"catalog.authorization.id": "AUT-9288-6146",
2122
"catalog.listing.id": "LST-5489-0806",
2223
"catalog.price_list.id": "PRC-7255-3950-0245",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
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"}}
1+
{"externalIds": {"vendor": "ext-seeded-billing-sub-vendor-id", "invoice": "INV12345", "reference": "ORD-2413-8980-9419"}, "search": {"source": {"type": "Subscription", "criteria": "id", "value": "SUB-0356-5642-8669"},"order":{"criteria":"order.id","value":"ORD-2413-8980-9419"}, "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"}}
6 Bytes
Binary file not shown.
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 journal_charge_id(e2e_config):
6+
return e2e_config["billing.journal.charge.id"]
7+
8+
9+
@pytest.fixture
10+
def invalid_journal_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 journal_charges(async_mpt_vendor, billing_journal_id):
11+
return async_mpt_vendor.billing.journals.charges(billing_journal_id)
12+
13+
14+
async def test_get_journal_charge_by_id(journal_charges, journal_charge_id):
15+
result = await journal_charges.get(journal_charge_id)
16+
17+
assert result is not None
18+
19+
20+
async def test_get_journal_charge_by_id_not_found(journal_charges, invalid_journal_charge_id):
21+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
22+
await journal_charges.get(invalid_journal_charge_id)
23+
24+
25+
async def test_list_journal_charges(journal_charges):
26+
limit = 10
27+
28+
result = await journal_charges.fetch_page(limit=limit)
29+
30+
assert len(result) > 0
31+
32+
33+
async def test_filter_journal_charges(journal_charges, journal_charge_id):
34+
select_fields = ["-period"]
35+
filtered_charges = (
36+
journal_charges.filter(RQLQuery(id=journal_charge_id))
37+
.filter(RQLQuery(externalIds__invoice="INV12345"))
38+
.select(*select_fields)
39+
)
40+
41+
result = [charges async for charges 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 journal_charges(mpt_vendor, billing_journal_id):
11+
return mpt_vendor.billing.journals.charges(billing_journal_id)
12+
13+
14+
def test_get_journal_charge_by_id(journal_charges, journal_charge_id):
15+
result = journal_charges.get(journal_charge_id)
16+
17+
assert result is not None
18+
19+
20+
def test_get_journal_charge_by_id_not_found(journal_charges, invalid_journal_charge_id):
21+
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
22+
journal_charges.get(invalid_journal_charge_id)
23+
24+
25+
def test_list_journal_charges(journal_charges):
26+
limit = 10
27+
28+
result = journal_charges.fetch_page(limit=limit)
29+
30+
assert len(result) > 0
31+
32+
33+
def test_filter_journal_charges(journal_charges, journal_charge_id):
34+
select_fields = ["-period"]
35+
filtered_charges = (
36+
journal_charges.filter(RQLQuery(id=journal_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

0 commit comments

Comments
 (0)