30 lines
976 B
Python
30 lines
976 B
Python
# #region Test.ServicesInit [C:2] [TYPE Module] [SEMANTICS test,services,init,lazy-loading]
|
|
# @BRIEF Tests for services/__init__.py — lazy-loading __getattr__.
|
|
# @RELATION BINDS_TO -> [services]
|
|
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src"))
|
|
|
|
import pytest
|
|
|
|
|
|
class TestServicesInit:
|
|
def test_getattr_mapping_service(self):
|
|
import src.services as svc
|
|
ms = svc.MappingService
|
|
from src.services.mapping_service import MappingService
|
|
assert ms is MappingService
|
|
|
|
def test_getattr_resource_service(self):
|
|
import src.services as svc
|
|
rs = svc.ResourceService
|
|
from src.services.resource_service import ResourceService
|
|
assert rs is ResourceService
|
|
|
|
def test_getattr_raises_for_unknown(self):
|
|
import src.services as svc
|
|
with pytest.raises(AttributeError, match="has no attribute"):
|
|
svc.__getattr__("NonExistentService")
|