|
| 1 | +import pytest |
| 2 | + |
| 3 | +from mpt_api_client.resources.audit.audit import AsyncAudit, Audit |
| 4 | +from mpt_api_client.resources.audit.records import AsyncRecordsService, RecordsService |
| 5 | + |
| 6 | + |
| 7 | +@pytest.fixture |
| 8 | +def audit(http_client): |
| 9 | + return Audit(http_client=http_client) |
| 10 | + |
| 11 | + |
| 12 | +@pytest.fixture |
| 13 | +def async_audit(async_http_client): |
| 14 | + return AsyncAudit(http_client=async_http_client) |
| 15 | + |
| 16 | + |
| 17 | +@pytest.mark.parametrize( |
| 18 | + ("property_name", "expected_service_class"), |
| 19 | + [ |
| 20 | + ("records", RecordsService), |
| 21 | + ], |
| 22 | +) |
| 23 | +def test_audit_properties(audit, property_name, expected_service_class): |
| 24 | + """Test that Audit properties return correct instances.""" |
| 25 | + service = getattr(audit, property_name) |
| 26 | + |
| 27 | + assert isinstance(service, expected_service_class) |
| 28 | + assert service.http_client is audit.http_client |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.parametrize( |
| 32 | + ("property_name", "expected_service_class"), |
| 33 | + [ |
| 34 | + ("records", AsyncRecordsService), |
| 35 | + ], |
| 36 | +) |
| 37 | +def test_async_audit_properties(async_audit, property_name, expected_service_class): |
| 38 | + """Test that AsyncAudit properties return correct instances.""" |
| 39 | + service = getattr(async_audit, property_name) |
| 40 | + |
| 41 | + assert isinstance(service, expected_service_class) |
| 42 | + assert service.http_client is async_audit.http_client |
| 43 | + |
| 44 | + |
| 45 | +def test_audit_initialization(http_client): |
| 46 | + audit = Audit(http_client=http_client) |
| 47 | + |
| 48 | + assert audit.http_client is http_client |
| 49 | + assert isinstance(audit, Audit) |
| 50 | + |
| 51 | + |
| 52 | +def test_async_audit_initialization(async_http_client): |
| 53 | + async_audit = AsyncAudit(http_client=async_http_client) |
| 54 | + |
| 55 | + assert async_audit.http_client is async_http_client |
| 56 | + assert isinstance(async_audit, AsyncAudit) |
0 commit comments