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
2 changes: 1 addition & 1 deletion .github/workflows/cron-main-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 60
steps:
- name: "Checkout"
uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 60

steps:
- name: "Checkout"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 60

steps:
- name: "Checkout"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:

runs-on: ubuntu-latest
timeout-minutes: 45
timeout-minutes: 60

steps:
- name: "Checkout"
Expand Down
2 changes: 2 additions & 0 deletions e2e_config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"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",
"billing.statement.charge.id": "CHG-2589-1434-0000-0000-0200",
"billing.statement.id": "SOM-7311-9982-9805-9250",
"catalog.authorization.id": "AUT-9288-6146",
"catalog.listing.id": "LST-5489-0806",
"catalog.price_list.id": "PRC-7255-3950-0245",
Expand Down
11 changes: 11 additions & 0 deletions tests/e2e/billing/statement/charge/conftest.py
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"
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
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
11 changes: 11 additions & 0 deletions tests/e2e/billing/statement/conftest.py
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"
38 changes: 38 additions & 0 deletions tests/e2e/billing/statement/test_async_statement.py
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
38 changes: 38 additions & 0 deletions tests/e2e/billing/statement/test_sync_statement.py
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