Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"billing.custom_ledger.attachment.id": "CLA-1777-7485",
"billing.custom_ledger.charge.id": "CHG-2665-3524-0000-0000-0020",
"billing.custom_ledger.id": "CLE-2665-3524",
"billing.journal.attachment.id": "JOA-6425-9776",
"billing.journal.id": "BJO-6562-0928",
"billing.journal.attachment.id": "JOA-2849-3620",
"billing.journal.charge.id": "CHG-2589-1434-0000-0000-0200",
"billing.journal.id": "BJO-2589-1434",
"billing.ledger.attachment.id": "LEA-4971-4321",
"billing.ledger.charge.id": "CHG-2589-1434-0000-0000-0200",
"billing.ledger.id": "BLE-2589-1434-7310-3075",
Expand Down
2 changes: 1 addition & 1 deletion tests/data/test_billing_journal.jsonl
Original file line number Diff line number Diff line change
@@ -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"}}
{"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"}}
Binary file modified tests/data/test_billing_journal.xlsx
Binary file not shown.
11 changes: 11 additions & 0 deletions tests/e2e/billing/journal/charge/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.fixture
def journal_charge_id(e2e_config):
return e2e_config["billing.journal.charge.id"]


@pytest.fixture
def invalid_journal_charge_id():
return "CHG-0000-0000-0000-0000-0000"
43 changes: 43 additions & 0 deletions tests/e2e/billing/journal/charge/test_async_journal_charge.py
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 journal_charges(async_mpt_vendor, billing_journal_id):
return async_mpt_vendor.billing.journals.charges(billing_journal_id)


async def test_get_journal_charge_by_id(journal_charges, journal_charge_id):
result = await journal_charges.get(journal_charge_id)

assert result is not None


async def test_get_journal_charge_by_id_not_found(journal_charges, invalid_journal_charge_id):
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
await journal_charges.get(invalid_journal_charge_id)


async def test_list_journal_charges(journal_charges):
limit = 10

result = await journal_charges.fetch_page(limit=limit)

assert len(result) > 0


async def test_filter_journal_charges(journal_charges, journal_charge_id):
select_fields = ["-period"]
filtered_charges = (
journal_charges.filter(RQLQuery(id=journal_charge_id))
.filter(RQLQuery(externalIds__invoice="INV12345"))
.select(*select_fields)
)

result = [charges async for charges in filtered_charges.iterate()]

assert len(result) == 1
43 changes: 43 additions & 0 deletions tests/e2e/billing/journal/charge/test_sync_journal_charge.py
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 journal_charges(mpt_vendor, billing_journal_id):
return mpt_vendor.billing.journals.charges(billing_journal_id)


def test_get_journal_charge_by_id(journal_charges, journal_charge_id):
result = journal_charges.get(journal_charge_id)

assert result is not None


def test_get_journal_charge_by_id_not_found(journal_charges, invalid_journal_charge_id):
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
journal_charges.get(invalid_journal_charge_id)


def test_list_journal_charges(journal_charges):
limit = 10

result = journal_charges.fetch_page(limit=limit)

assert len(result) > 0


def test_filter_journal_charges(journal_charges, journal_charge_id):
select_fields = ["-period"]
filtered_charges = (
journal_charges.filter(RQLQuery(id=journal_charge_id))
.filter(RQLQuery(externalIds__invoice="INV12345"))
.select(*select_fields)
)

result = list(filtered_charges.iterate())

assert len(result) == 1