와일들카드 선택 수정 .
This commit is contained in:
1 parent
8c700b1e08
commit
15f3d10eb6
11 files changed
+266
-10
No files matched your search
@@ -15,6 +15,8 @@ import pytest
|
||||
|
||||
from router.v1.chat.protocol import Req_Chat
|
||||
from services.chat_service import ChatService, reset_sessions
|
||||
from negotiation.chat.service.chat_engine import ChatEngine, ChatSession
|
||||
from negotiation.chat.service.script_repository import ScriptRepository
|
||||
from negotiation.qtable.infra.repository.learning_repository import LearningRepository
|
||||
from tenancy.config_loader import TenantConfigLoader
|
||||
from tenancy.registry import TenantEngineRegistry
|
||||
@@ -122,6 +124,75 @@ def test_acceptance_ratio_dynamic_calc():
|
||||
assert calc({"input_price": 9800}) == 0.0 # 기준가 전무(과거 세션 호환)
|
||||
|
||||
|
||||
def test_selected_card_mapping_overrides_tenant_default():
|
||||
"""운영 세션은 견적 version_id 에 묶인 카드 번호를 action_id 순서로 사용한다."""
|
||||
session = ChatSession(
|
||||
session_id="00000000-0000-0000-0000-000000000001",
|
||||
tenant_id="ktcommerce",
|
||||
company_id="ktcommerce",
|
||||
context={"selected_nego_card_numbers": ["2", "7"]},
|
||||
action_space_size=2,
|
||||
)
|
||||
class _Mapper:
|
||||
def get_card_id(self, action_id):
|
||||
return f"DEFAULT-{action_id}"
|
||||
class _Engine:
|
||||
mapper = _Mapper()
|
||||
|
||||
assert ChatService._card_id_for_action(_Engine(), session, 0) == "2"
|
||||
assert ChatService._card_id_for_action(_Engine(), session, 1) == "7"
|
||||
assert ChatService._card_id_for_action(_Engine(), session, 8) == "DEFAULT-8"
|
||||
|
||||
|
||||
def test_default_1pct_wildcard_still_runs_without_selected_wildcard():
|
||||
"""1% 인하는 기본 제공 카드라 DB 견적에서 와일드카드를 선택하지 않아도 발동한다."""
|
||||
cfg = TenantConfigLoader(tenants_dir=_TENANTS_DIR, cache_ttl_seconds=0).load("ktcommerce")
|
||||
repo = ScriptRepository(cfg, _TENANTS_DIR)
|
||||
engine = ChatEngine(repo, rq_type="재협상")
|
||||
session = ChatSession(
|
||||
session_id="00000000-0000-0000-0000-000000000002",
|
||||
tenant_id="ktcommerce",
|
||||
company_id="ktcommerce",
|
||||
step="가격협상_확인",
|
||||
action_space_size=0,
|
||||
context={
|
||||
"input_price": 10000,
|
||||
"anchor_price": 9900,
|
||||
"target_price": 10000,
|
||||
"round": 1,
|
||||
"allow_selected_wildcards": False,
|
||||
},
|
||||
)
|
||||
|
||||
view = engine.advance(session, "예")
|
||||
assert view.step == "wild_card_1pct"
|
||||
|
||||
|
||||
def test_budget_wildcard_requires_selected_wildcard_for_db_context():
|
||||
"""재원부족 구간은 DB 견적에서 와일드카드를 선택했을 때만 발동한다."""
|
||||
cfg = TenantConfigLoader(tenants_dir=_TENANTS_DIR, cache_ttl_seconds=0).load("ktcommerce")
|
||||
repo = ScriptRepository(cfg, _TENANTS_DIR)
|
||||
engine = ChatEngine(repo, rq_type="재협상")
|
||||
session = ChatSession(
|
||||
session_id="00000000-0000-0000-0000-000000000003",
|
||||
tenant_id="ktcommerce",
|
||||
company_id="ktcommerce",
|
||||
step="가격협상_확인",
|
||||
action_space_size=0,
|
||||
context={
|
||||
"input_price": 10200,
|
||||
"anchor_price": 9900,
|
||||
"target_price": 10000,
|
||||
"round": 1,
|
||||
"allow_selected_wildcards": False,
|
||||
},
|
||||
)
|
||||
|
||||
view = engine.advance(session, "예")
|
||||
assert view.step == "가격협상"
|
||||
assert not view.step.startswith("wild_card_")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_priority_completes_without_wildcard(db_engine):
|
||||
reset_sessions()
|
||||
|
||||
Reference in new issue
Block a user