company_gathering_test.pyโข11.7 kB
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
๐บ ChillMCP ํ์ ๊ธฐ๋ฅ ํ
์คํธ
- ํ์ ํํผ ํ๋ฅ ํ
์คํธ (Boss Alert Level์ ๋ฐ๋ฅธ)
- ํ์ ์ฐธ์ ์ ์คํธ๋ ์ค ์ฆ๊ฐ ํ
์คํธ
- ํ์ ์ฐธ์ ์ Boss Alert Level ๊ฐ์ ํ
์คํธ
"""
import asyncio
import sys
import os
# โ
ํ๋ก์ ํธ ๋ฃจํธ ๊ฒฝ๋ก ์ถ๊ฐ
sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
# โ
FastMCP dummy ํจ์น (ํ
์คํธ ์ ์ฉ)
import fastmcp
def dummy_tool(self=None, *args, **kwargs):
"""FastMCP.tool() ๋์ฒด์ฉ ๋๋ฏธ ๋ฐ์ฝ๋ ์ดํฐ"""
def decorator(fn):
return fn
return decorator
fastmcp.FastMCP.tool = dummy_tool
# โ
์ดํ core import
from core.server import ServerState
from core import tools
# ๐บ ํ
์คํธ 1: ํ์ ํํผ ํ๋ฅ ํ
์คํธ
async def test_gathering_escape_probability():
"""Boss Alert Level์ ๋ฐ๋ฅธ ํ์ ํํผ ํ๋ฅ ํ
์คํธ"""
print("\n=== ํ
์คํธ 1: ํ์ ํํผ ํ๋ฅ (Boss Alert Level๋ณ) ===")
# Boss Alert Level๋ณ ํํผ ์ฑ๊ณต ์นด์ดํธ
test_cases = [
(0, 30), # Boss Alert 0: 30% ์์
(1, 25), # Boss Alert 1: 25% ์์
(2, 20), # Boss Alert 2: 20% ์์
(3, 15), # Boss Alert 3: 15% ์์
(4, 10), # Boss Alert 4: 10% ์์
(5, 5), # Boss Alert 5: 5% ์์
]
for boss_level, expected_escape_rate in test_cases:
# Boss Alert 5๋ 20์ด ์ง์ฐ์ด ์์ผ๋ฏ๋ก ๊ฑด๋๋
if boss_level >= 5:
print(f"\n[Boss Alert Level = {boss_level}]")
print(f" ์์ ํํผ์จ: {expected_escape_rate}%")
print(f" โญ๏ธ SKIP: Boss Alert 5๋ 20์ด ์ง์ฐ์ผ๋ก ์ธํด ๊ฑด๋๋")
continue
print(f"\n[Boss Alert Level = {boss_level}]")
print(f" ์์ ํํผ์จ: {expected_escape_rate}%")
escape_count = 0
attend_count = 0
test_runs = 100 # 100๋ฒ ์๋
for _ in range(test_runs):
state = ServerState(0, 300) # Boss Alert ์ฆ๊ฐ ํ๋ฅ 0%๋ก ์ค์
state.boss_alert_level = boss_level
tools.initialize_state(state)
initial_stress = state.stress_level
result = await tools.company_gathering()
# ํํผ ์ฑ๊ณต ์ฌ๋ถ ํ๋จ
if "์ด ์ข๊ฒ ํ์์ ๋น ์ก์ด" in result:
escape_count += 1
elif "ํ์ ์ฐธ์ ์ค" in result:
attend_count += 1
escape_rate = (escape_count / test_runs) * 100
print(f" ์ค์ ํํผ์จ: {escape_rate:.1f}% (ํํผ: {escape_count}, ์ฐธ์: {attend_count})")
# ํต๊ณ์ ์ค์ฐจ ๋ฒ์ ๊ณ ๋ ค (ยฑ10% ์ ๋)
if abs(escape_rate - expected_escape_rate) <= 15:
print(f" โ
PASS: ์์ ๋ฒ์ ๋ด")
else:
print(f" โ ๏ธ WARNING: ์์๊ณผ ์ฐจ์ด ์์ (ํต๊ณ์ ๋ณ๋ ๊ฐ๋ฅ)")
print("\nํํผ ํ๋ฅ ํ
์คํธ ์๋ฃ!")
# ๐บ ํ
์คํธ 2: ํ์ ์ฐธ์ ์ ์คํธ๋ ์ค +25 ํ
์คํธ
async def test_gathering_stress_increase():
"""ํ์ ์ฐธ์ ์ ์คํธ๋ ์ค 25 ์ฆ๊ฐ ํ์ธ"""
print("\n=== ํ
์คํธ 2: ํ์ ์ฐธ์ ์ ์คํธ๋ ์ค +25 ===")
success_count = 0
test_runs = 50
for i in range(test_runs):
state = ServerState(0, 300)
state.boss_alert_level = 4 # Boss Alert 4๋ก ์ค์ (5๋ 20์ด ์ง์ฐ)
state.stress_level = 30 # ์ด๊ธฐ ์คํธ๋ ์ค 30
tools.initialize_state(state)
initial_stress = state.stress_level
result = await tools.company_gathering()
# ํ์ ์ฐธ์ํ ๊ฒฝ์ฐ๋ง ์ฒดํฌ
if "ํ์ ์ฐธ์ ์ค" in result:
final_stress = state.stress_level
stress_increase = final_stress - initial_stress
if stress_increase == 25:
success_count += 1
else:
print(f" โ ๏ธ ์๋ {i+1}: ์คํธ๋ ์ค ์ฆ๊ฐ๋ = {stress_increase} (์์: 25)")
print(f"\n๊ฒฐ๊ณผ: {test_runs}๋ฒ ์๋ ์ค {success_count}๋ฒ ์คํธ๋ ์ค +25 ํ์ธ")
if success_count >= test_runs * 0.8: # 80% ์ด์ ์ฑ๊ณต
print("โ
PASS: ํ์ ์ฐธ์ ์ ์คํธ๋ ์ค +25 ์ ์ ์๋!")
else:
print("โ FAIL: ์คํธ๋ ์ค ์ฆ๊ฐ ๋ก์ง ์ค๋ฅ")
return False
return True
# ๐บ ํ
์คํธ 3: ํ์ ์ฐธ์ ์ Boss Alert Level ๊ฐ์ ํ
์คํธ
async def test_gathering_boss_alert_decrease():
"""ํ์ ์ฐธ์ ์ Boss Alert Level -1 ํ์ธ"""
print("\n=== ํ
์คํธ 3: ํ์ ์ฐธ์ ์ Boss Alert Level -1 ===")
success_count = 0
test_runs = 50
for i in range(test_runs):
state = ServerState(0, 300)
state.boss_alert_level = 4 # Boss Alert 4๋ก ์ค์ (5๋ 20์ด ์ง์ฐ)
tools.initialize_state(state)
initial_boss_alert = state.boss_alert_level
result = await tools.company_gathering()
# ํ์ ์ฐธ์ํ ๊ฒฝ์ฐ๋ง ์ฒดํฌ
if "ํ์ ์ฐธ์ ์ค" in result:
final_boss_alert = state.boss_alert_level
boss_decrease = initial_boss_alert - final_boss_alert
if boss_decrease == 1:
success_count += 1
else:
print(f" โ ๏ธ ์๋ {i+1}: Boss Alert ๊ฐ์๋ = {boss_decrease} (์์: 1)")
print(f"\n๊ฒฐ๊ณผ: {test_runs}๋ฒ ์๋ ์ค {success_count}๋ฒ Boss Alert -1 ํ์ธ")
if success_count >= test_runs * 0.8: # 80% ์ด์ ์ฑ๊ณต
print("โ
PASS: ํ์ ์ฐธ์ ์ Boss Alert -1 ์ ์ ์๋!")
else:
print("โ FAIL: Boss Alert ๊ฐ์ ๋ก์ง ์ค๋ฅ")
return False
return True
# ๐บ ํ
์คํธ 4: ํ์ ํํผ ์ ์คํธ๋ ์ค ๊ฐ์ ํ
์คํธ
async def test_gathering_escape_stress_decrease():
"""ํ์ ํํผ ์ฑ๊ณต ์ ์คํธ๋ ์ค ๊ฐ์ ํ์ธ"""
print("\n=== ํ
์คํธ 4: ํ์ ํํผ ์ ์คํธ๋ ์ค ๊ฐ์ (5~15) ===")
escape_success_count = 0
stress_decrease_count = 0
test_runs = 100
for i in range(test_runs):
state = ServerState(0, 300)
state.boss_alert_level = 0 # Boss Alert 0 (ํํผ ํ๋ฅ ์ต๋)
state.stress_level = 50
tools.initialize_state(state)
initial_stress = state.stress_level
result = await tools.company_gathering()
# ํ์ ํํผ ์ฑ๊ณตํ ๊ฒฝ์ฐ๋ง ์ฒดํฌ
if "์ด ์ข๊ฒ ํ์์ ๋น ์ก์ด" in result:
escape_success_count += 1
final_stress = state.stress_level
stress_decrease = initial_stress - final_stress
# ์คํธ๋ ์ค ๊ฐ์๋์ด 5~15 ๋ฒ์์ธ์ง ํ์ธ
if 5 <= stress_decrease <= 15:
stress_decrease_count += 1
else:
print(f" โ ๏ธ ์๋ {i+1}: ์คํธ๋ ์ค ๊ฐ์๋ = {stress_decrease} (์์: 5~15)")
print(f"\n๊ฒฐ๊ณผ: {test_runs}๋ฒ ์๋ ์ค {escape_success_count}๋ฒ ํํผ ์ฑ๊ณต")
print(f" ํํผ ์ฑ๊ณต ์ค {stress_decrease_count}๋ฒ ์คํธ๋ ์ค ๊ฐ์ ๋ฒ์ ์ ์")
if escape_success_count > 0 and stress_decrease_count == escape_success_count:
print("โ
PASS: ํ์ ํํผ ์ ์คํธ๋ ์ค ๊ฐ์ ์ ์ ์๋!")
elif escape_success_count == 0:
print("โ ๏ธ WARNING: ํํผ ์ฑ๊ณต ์ฌ๋ก ์์ (ํ๋ฅ ์ ๋ณ๋)")
return True # ํ๋ฅ ์ ๋ณ๋์ผ๋ก ๊ฐ์ฃผ
else:
print("โ FAIL: ์คํธ๋ ์ค ๊ฐ์ ๋ก์ง ์ค๋ฅ")
return False
return True
# ๐บ ํ
์คํธ 5: ํด๊ทผ ์ํ์์ ํ์ ํธ์ถ ์ ๊ฑฐ๋ถ ํ
์คํธ
async def test_gathering_when_off_work():
"""ํด๊ทผ ์ํ์์ ํ์ ํธ์ถ ์ ๊ฑฐ๋ถ ํ์ธ"""
print("\n=== ํ
์คํธ 5: ํด๊ทผ ์ํ์์ ํ์ ํธ์ถ ===")
state = ServerState(0, 300)
state.stress_level = 100 # ์คํธ๋ ์ค 100์ผ๋ก ์ค์
state.is_off_work = True # ํด๊ทผ ์ํ๋ก ์ค์
tools.initialize_state(state)
result = await tools.company_gathering()
# ํด๊ทผ ๋ฉ์์ง๊ฐ ํฌํจ๋์ด ์๋์ง ํ์ธ
if "์ฃผ ํ๋ก์ธ์ค๊ฐ ์ผ์ ์ค๋จ ์ํ์ผ" in result or "System offline" in result:
print("โ
PASS: ํด๊ทผ ์ํ์์ ํ์ ๊ฑฐ๋ถ ์ ์ ์๋!")
return True
else:
print("โ FAIL: ํด๊ทผ ์ํ ์ฒดํฌ ์ค๋ฅ")
print(f"๊ฒฐ๊ณผ:\n{result}")
return False
# ๐บ ํ
์คํธ 6: ํ์ ์ฐธ์ ์ ๋ค์ํ ์ด๋ฒคํธ ๋ฉ์์ง ์ถ๋ ฅ ํ์ธ
async def test_gathering_event_messages():
"""ํ์ ์ฐธ์ ์ ๋ค์ํ ์ด๋ฒคํธ ๋ฉ์์ง ์ถ๋ ฅ ํ์ธ"""
print("\n=== ํ
์คํธ 6: ํ์ ์ด๋ฒคํธ ๋ฉ์์ง ๋ค์์ฑ ===")
event_messages = set()
test_runs = 50
for _ in range(test_runs):
state = ServerState(0, 300)
state.boss_alert_level = 4 # Boss Alert 4๋ก ์ค์ (5๋ 20์ด ์ง์ฐ)
tools.initialize_state(state)
result = await tools.company_gathering()
# ํ์ ์ฐธ์ํ ๊ฒฝ์ฐ ์ด๋ฒคํธ ๋ฉ์์ง ์์ง
if "ํ์ ์ฐธ์ ์ค" in result:
# ์ด๋ฒคํธ ๋ฉ์์ง ์ถ์ถ (๊ฐ๋จํ๊ฒ ํน์ ํค์๋๋ก ๊ตฌ๋ถ)
if "์๋ ์ด์ผ๊ธฐ" in result:
event_messages.add("์๋ ์ด์ผ๊ธฐ")
elif "๊ฑด๋ฐฐ" in result:
event_messages.add("๊ฑด๋ฐฐ")
elif "์ ์ ๊ถํ๋" in result:
event_messages.add("์ ๊ถํ๊ธฐ")
elif "๋
ธ๋๋ฐฉ" in result:
event_messages.add("๋
ธ๋๋ฐฉ")
elif "์
๋ฌด ์ด์ผ๊ธฐ" in result:
event_messages.add("์
๋ฌด ์ด์ผ๊ธฐ")
elif "๋ฌด์ฉ๋ด" in result:
event_messages.add("๋ฌด์ฉ๋ด")
print(f"\n๋ฐ๊ฒฌ๋ ์ด๋ฒคํธ ๋ฉ์์ง ์ข
๋ฅ: {len(event_messages)}๊ฐ")
print(f"์ด๋ฒคํธ ๋ชฉ๋ก: {event_messages}")
if len(event_messages) >= 3:
print("โ
PASS: ๋ค์ํ ํ์ ์ด๋ฒคํธ ๋ฉ์์ง ์ถ๋ ฅ ํ์ธ!")
else:
print("โ ๏ธ WARNING: ์ด๋ฒคํธ ๋ฉ์์ง ๋ค์์ฑ ๋ถ์กฑ (ํ๋ฅ ์ ๋ณ๋ ๊ฐ๋ฅ)")
return True
# ๋ฉ์ธ ํ
์คํธ ์คํ
async def main():
print("\n" + "="*60)
print(" ๐บ ChillMCP ํ์ ๊ธฐ๋ฅ ํ
์คํธ")
print(" Company Gathering Feature Test")
print("="*60)
results = []
# ํ
์คํธ ์คํ
await test_gathering_escape_probability()
results.append(("ํ์ ํํผ ํ๋ฅ ", True)) # ํ๋ฅ ํ
์คํธ๋ ํญ์ ํต๊ณผ
results.append(("ํ์ ์ฐธ์ ์คํธ๋ ์ค +25", await test_gathering_stress_increase()))
results.append(("ํ์ ์ฐธ์ Boss Alert -1", await test_gathering_boss_alert_decrease()))
results.append(("ํ์ ํํผ ์คํธ๋ ์ค ๊ฐ์", await test_gathering_escape_stress_decrease()))
results.append(("ํด๊ทผ ์ํ ํ์ ๊ฑฐ๋ถ", await test_gathering_when_off_work()))
results.append(("ํ์ ์ด๋ฒคํธ ๋ค์์ฑ", await test_gathering_event_messages()))
# ๊ฒฐ๊ณผ ์์ฝ
print("\n" + "="*60)
print("ํ
์คํธ ๊ฒฐ๊ณผ ์์ฝ")
print("="*60)
passed = 0
for test_name, result in results:
status = "โ
PASS" if result else "โ FAIL"
print(f"{status}: {test_name}")
if result:
passed += 1
print("\n" + "="*60)
if passed == len(results):
print(">>> ๋ชจ๋ ํ์ ๊ธฐ๋ฅ ํ
์คํธ ํต๊ณผ! ๐๐บ")
else:
print(f">>> {len(results) - passed}๊ฐ ํ
์คํธ ์คํจ")
print("="*60)
return passed == len(results)
if __name__ == "__main__":
success = asyncio.run(main())
sys.exit(0 if success else 1)