43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""审计本体约束测试(无需数据库)。"""
|
|
|
|
from app.datahub.ontology import EntityType, RelationshipType, is_valid_relationship
|
|
|
|
|
|
def test_valid_signed_relationship():
|
|
assert is_valid_relationship(
|
|
RelationshipType.SIGNED, EntityType.CUSTOMER, EntityType.CONTRACT
|
|
)
|
|
|
|
|
|
def test_invalid_signed_direction():
|
|
# 合同不能"签约"客户(方向反了)
|
|
assert not is_valid_relationship(
|
|
RelationshipType.SIGNED, EntityType.CONTRACT, EntityType.CUSTOMER
|
|
)
|
|
|
|
|
|
def test_legal_rep_relationship():
|
|
assert is_valid_relationship(
|
|
RelationshipType.LEGAL_REP_OF, EntityType.LEGAL_PERSON, EntityType.SUPPLIER
|
|
)
|
|
|
|
|
|
def test_related_to_between_legal_persons():
|
|
# 实控人关联识别的基础:法人之间的亲属/关联关系
|
|
assert is_valid_relationship(
|
|
RelationshipType.RELATED_TO, EntityType.LEGAL_PERSON, EntityType.LEGAL_PERSON
|
|
)
|
|
|
|
|
|
def test_invalid_relationship_wrong_target():
|
|
assert not is_valid_relationship(
|
|
RelationshipType.HOLDS_MSISDN, EntityType.CUSTOMER, EntityType.CONTRACT
|
|
)
|
|
|
|
|
|
def test_all_relationship_types_have_domain():
|
|
from app.datahub.ontology import RELATIONSHIP_DOMAIN
|
|
|
|
for rel in RelationshipType:
|
|
assert rel in RELATIONSHIP_DOMAIN, f"关系 {rel} 缺少本体域定义"
|