-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_async_ledger.py
More file actions
38 lines (23 loc) · 1.1 KB
/
test_async_ledger.py
File metadata and controls
38 lines (23 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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_billing_ledger_by_id(async_mpt_ops, ledger_id):
result = await async_mpt_ops.billing.ledgers.get(ledger_id)
assert result is not None
async def test_list_billing_ledgers(async_mpt_ops):
limit = 10
result = await async_mpt_ops.billing.ledgers.fetch_page(limit=limit)
assert len(result) > 0
async def test_get_billing_ledger_by_id_not_found(async_mpt_ops, invalid_ledger_id):
with pytest.raises(MPTAPIError, match=r"404 Not Found"):
await async_mpt_ops.billing.ledgers.get(invalid_ledger_id)
async def test_filter_billing_ledgers(async_mpt_ops, ledger_id, commerce_product_id):
select_fields = ["-authorization"]
filtered_ledgers = (
async_mpt_ops.billing.ledgers.filter(RQLQuery(id=ledger_id))
.filter(RQLQuery(f"product.id={commerce_product_id}"))
.select(*select_fields)
)
result = [ledger async for ledger in filtered_ledgers.iterate()]
assert len(result) > 0