Files
tk-factory-services/tkeg/api/app/services/test_fitting_classifier.py
2026-03-27 07:08:17 +09:00

177 lines
5.8 KiB
Python

"""
FITTING 분류 시스템 V2 테스트 (크기 정보 추가)
"""
from .fitting_classifier import classify_fitting, get_fitting_purchase_info
def test_fitting_classification():
"""실제 BOM 데이터로 FITTING 분류 테스트"""
test_cases = [
{
"name": "90도 엘보 (BW)",
"dat_file": "90L_BW",
"description": "90 LR ELL, SCH 40, ASTM A234 GR WPB, SMLS",
"main_nom": "3\"",
"red_nom": None
},
{
"name": "리듀싱 티 (BW)",
"dat_file": "TEE_RD_BW",
"description": "TEE RED, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
"main_nom": "4\"",
"red_nom": "2\""
},
{
"name": "동심 리듀서 (BW)",
"dat_file": "CNC_BW",
"description": "RED CONC, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
"main_nom": "3\"",
"red_nom": "2\""
},
{
"name": "편심 리듀서 (BW)",
"dat_file": "ECC_BW",
"description": "RED ECC, SCH 40 x SCH 40, ASTM A234 GR WPB, SMLS",
"main_nom": "6\"",
"red_nom": "3\""
},
{
"name": "소켓웰드 티 (고압)",
"dat_file": "TEE_SW_3000",
"description": "TEE, SW, 3000LB, ASTM A105",
"main_nom": "1\"",
"red_nom": None
},
{
"name": "리듀싱 소켓웰드 티 (고압)",
"dat_file": "TEE_RD_SW_3000",
"description": "TEE RED, SW, 3000LB, ASTM A105",
"main_nom": "1\"",
"red_nom": "1/2\""
},
{
"name": "소켓웰드 캡 (고압)",
"dat_file": "CAP_SW_3000",
"description": "CAP, NPT(F), 3000LB, ASTM A105",
"main_nom": "1\"",
"red_nom": None
},
{
"name": "소켓오렛 (고압)",
"dat_file": "SOL_SW_3000",
"description": "SOCK-O-LET, SW, 3000LB, ASTM A105",
"main_nom": "3\"",
"red_nom": "1\""
},
{
"name": "동심 스웨지 (BW)",
"dat_file": "SWG_CN_BW",
"description": "SWAGE CONC, SCH 40 x SCH 80, ASTM A105 GR , SMLS BBE",
"main_nom": "2\"",
"red_nom": "1\""
},
{
"name": "편심 스웨지 (BW)",
"dat_file": "SWG_EC_BW",
"description": "SWAGE ECC, SCH 80 x SCH 80, ASTM A105 GR , SMLS PBE",
"main_nom": "1\"",
"red_nom": "3/4\""
}
]
print("🔧 FITTING 분류 시스템 V2 테스트 시작\n")
print("=" * 80)
for i, test in enumerate(test_cases, 1):
print(f"\n테스트 {i}: {test['name']}")
print("-" * 60)
result = classify_fitting(
test["dat_file"],
test["description"],
test["main_nom"],
test["red_nom"]
)
purchase_info = get_fitting_purchase_info(result)
print(f"📋 입력:")
print(f" DAT_FILE: {test['dat_file']}")
print(f" DESCRIPTION: {test['description']}")
print(f" SIZE: {test.get('main_nom', '')}")
print(f"\n🔧 분류 결과:")
print(f" 피팅타입: {result['fitting_type']['type']} - {result['fitting_type']['subtype']}")
print(f" 연결방식: {result['connection_method']['method']}")
print(f" 압력등급: {result['pressure_rating']['rating']}")
print(f" 제작방법: {result['manufacturing']}")
print(f"\n📊 신뢰도:")
print(f" 전체신뢰도: {result['overall_confidence']}")
print(f" 피팅타입: {result['fitting_type']['confidence']}")
print(f" 연결방식: {result['connection_method']['confidence']}")
print(f"\n🛒 구매 정보:")
print(f" 공급업체: {purchase_info.get('supplier_type', 'N/A')}")
print(f" 구매카테고리: {purchase_info.get('purchase_category', 'N/A')}")
# 분류 요약
print(f"\n💾 분류 요약:")
print(f" 카테고리: {result.get('category', 'N/A')}")
print(f" 신뢰도: {result.get('overall_confidence', 'N/A')}")
if i < len(test_cases):
print("\n" + "=" * 80)
def test_fitting_edge_cases():
"""예외 케이스 테스트"""
edge_cases = [
{
"name": "DAT_FILE만 있는 경우",
"dat_file": "90L_BW",
"description": "",
"main_nom": "2\"",
"red_nom": None
},
{
"name": "DESCRIPTION만 있는 경우",
"dat_file": "",
"description": "90 DEGREE ELBOW, ASTM A234 WPB",
"main_nom": "3\"",
"red_nom": None
},
{
"name": "알 수 없는 DAT_FILE",
"dat_file": "UNKNOWN_CODE",
"description": "SPECIAL FITTING, CUSTOM MADE",
"main_nom": "4\"",
"red_nom": None
}
]
print("\n🧪 예외 케이스 테스트\n")
print("=" * 50)
for i, test in enumerate(edge_cases, 1):
print(f"\n예외 테스트 {i}: {test['name']}")
print("-" * 40)
result = classify_fitting(
test["dat_file"],
test["description"],
test["main_nom"],
test["red_nom"]
)
ft = result.get('fitting_type', {})
print(f"결과: {ft.get('type', 'N/A')} - {ft.get('subtype', 'N/A')}")
print(f"카테고리: {result.get('category', 'N/A')}")
print(f"신뢰도: {result.get('overall_confidence', 'N/A')}")
print(f"증거: {ft.get('evidence', [])}")
if __name__ == "__main__":
test_fitting_classification()
test_fitting_edge_cases()