Skip to content

테스트파일 정리 & 최적 시나리오 테스트#16

Merged
ArticPenguin merged 1 commit intomainfrom
dev-minwook
Oct 26, 2025
Merged

테스트파일 정리 & 최적 시나리오 테스트#16
ArticPenguin merged 1 commit intomainfrom
dev-minwook

Conversation

@ArticPenguin
Copy link
Contributor

No description provided.

@ArticPenguin ArticPenguin merged commit b3e762f into main Oct 26, 2025
1 check passed
@gemini-code-assist
Copy link

Summary of Changes

Hello @ArticPenguin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 풀 리퀘스트는 새로운 포괄적인 시나리오 기반 테스트 파일을 도입하고 기존 테스트 파일들을 재구성하여 테스트 스위트를 강화하는 데 중점을 둡니다. 새로운 테스트 파일은 도구 간의 다양한 상호작용, 스트레스 수준, 그리고 Boss Alert 메커니즘을 다루며, 특히 Boss Alert가 임계 수준에 도달했을 때의 견고한 동작을 보장합니다.

Highlights

  • 새로운 테스트 파일 추가: tests/test_all_tools_scenario.py 파일이 새로 추가되었습니다.
  • 시나리오 기반 테스트 강화: 새로 추가된 파일에는 모든 도구를 순차적으로 호출하는 종합 테스트, Boss Alert가 5에 도달했을 때 20초 지연이 발생하는 시나리오 테스트, 기본 도구 호출, Boss Alert 증가, 지연 확인, 선택적 도구 사용, leave_work를 통한 완전 리셋을 포함하는 완전한 워크플로우 시나리오, 시간 경과에 따른 스트레스 누적 및 다양한 휴식 도구를 사용한 스트레스 관리 테스트, 그리고 높은 Boss Alertness 설정 환경에서 모든 도구의 동작을 테스트하는 시나리오 등 상세한 테스트 시나리오가 포함되어 있습니다.
  • 테스트 파일 재구성: 기존 테스트 파일들(test_ascii.py, test_new_tools.py, validator.py)이 tests/ 디렉토리로 이동하여 정리되었습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 tests/test_all_tools_scenario.py에 포괄적인 시나리오 테스트를 추가하여 애플리케이션의 핵심 로직이 예상대로 작동하는지 확인하는 데 큰 도움이 됩니다. 테스트는 최대 상사 경계 수준 도달 및 스트레스 관리를 포함한 다양한 중요 워크플로우를 다룹니다. 또한 테스트 관련 파일을 tests/ 디렉토리로 이동하여 프로젝트 구조를 개선했습니다.

제 리뷰에는 테스트의 견고성, 유지보수성, 실행 속도를 개선하기 위한 제안이 포함되어 있습니다. 구체적으로 중복된 코드, 누락되거나 약한 단언문, 동적으로 처리할 수 있는 하드코딩된 값, 느린 시간 기반 검사 등이 있는 영역을 지적했습니다. 또한 테스트 로깅에 많은 print() 문이 사용되는 것을 확인했습니다. 더 깔끔한 테스트 실행을 위해 pytest의 출력 캡처 및 보고 기능에 의존하는 것이 좋습니다.

Comment on lines +191 to +204
if state_manager.boss_alert_level == 5:
print(" ✓ Boss Alert가 5에 도달!")

# Step 3: 20초 지연 확인
print("\n[Step 3] Boss Alert=5일 때 20초 지연 확인...")
start_time = time.time()
await tools.urgent_call(state_manager)
elapsed = time.time() - start_time

print(f" 경과 시간: {elapsed:.2f}초")
assert elapsed >= 20.0, f"Expected 20s delay, got {elapsed:.2f}s"
print(" ✓ 20초 지연 확인!")
else:
print(f" ⚠ Boss Alert가 5에 도달하지 못함 (현재: {state_manager.boss_alert_level})")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

if state_manager.boss_alert_level == 5: 구문은 boss_alert_level이 5에 도달하지 않으면 테스트의 중요한 부분(20초 지연 확인)을 조용히 건너뛰게 만듭니다. 이로 인해 잠재적인 버그를 놓칠 수 있습니다. boss_alert_level이 5에 도달하는 것을 assert로 강제하여 테스트의 신뢰성을 높이는 것이 좋습니다. 이렇게 하면 시나리오가 예상대로 동작하지 않을 때 테스트가 명확하게 실패하게 됩니다.

    assert state_manager.boss_alert_level == 5, f"Boss Alert가 5에 도달하지 못했습니다 (현재: {state_manager.boss_alert_level})"
    print("  ✓ Boss Alert가 5에 도달!")

    # Step 3: 20초 지연 확인
    print("\n[Step 3] Boss Alert=5일 때 20초 지연 확인...")
    start_time = time.time()
    await tools.urgent_call(state_manager)
    elapsed = time.time() - start_time

    print(f"  경과 시간: {elapsed:.2f}초")
    assert elapsed >= 20.0, f"Expected 20s delay, got {elapsed:.2f}s"
    print("  ✓ 20초 지연 확인!")

Comment on lines +286 to +290
for tool_func in tools_list:
before = state_manager.stress_level
await tool_func(state_manager)
after = state_manager.stress_level
print(f" - {tool_func.__name__}: {before} → {after} (변화: {after - before})")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

이 루프는 여러 휴식 도구를 실행하고 스트레스 레벨 변화를 출력하지만, 실제 동작을 검증하는 assert 구문이 없습니다. assert가 없는 테스트는 자동화된 검증을 수행하지 않으므로, 휴식 도구를 사용한 후에 스트레스 레벨이 실제로 감소했는지 확인하는 단언문을 추가해야 합니다.

    for tool_func in tools_list:
        before = state_manager.stress_level
        await tool_func(state_manager)
        after = state_manager.stress_level
        print(f"  - {tool_func.__name__}: {before}{after} (변화: {after - before})")
        assert after < before, f"{tool_func.__name__} 호출 후 스트레스가 감소해야 합니다."

Comment on lines +54 to +77
for tool_name, tool_func in basic_tools:
print(f"\n[{tool_name}] 호출 중...")
response = await tool_func(state_manager)
assert response is not None, f"{tool_name} returned None"
assert "Stress Level:" in response, f"{tool_name} missing Stress Level"
assert "Boss Alert Level:" in response, f"{tool_name} missing Boss Alert Level"
print(f"[{tool_name}] ✓ 성공")
print(f"현재 상태: Stress={state_manager.stress_level}, Boss Alert={state_manager.boss_alert_level}")

# 선택적 도구 3개
optional_tools = [
("chimaek", tools.chimaek),
("company_dinner", tools.company_dinner),
("leave_work", tools.leave_work), # leave_work는 마지막에 (리셋되므로)
]

for tool_name, tool_func in optional_tools:
print(f"\n[{tool_name}] 호출 중...")
response = await tool_func(state_manager)
assert response is not None, f"{tool_name} returned None"
assert "Stress Level:" in response, f"{tool_name} missing Stress Level"
assert "Boss Alert Level:" in response, f"{tool_name} missing Boss Alert Level"
print(f"[{tool_name}] ✓ 성공")
print(f"현재 상태: Stress={state_manager.stress_level}, Boss Alert={state_manager.boss_alert_level}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

basic_toolsoptional_tools를 테스트하는 두 개의 루프는 코드가 거의 동일합니다. 두 목록을 합쳐 하나의 루프로 처리하면 코드 중복을 줄이고 가독성을 높일 수 있습니다.

    all_tools = basic_tools + [
        ("chimaek", tools.chimaek),
        ("company_dinner", tools.company_dinner),
        ("leave_work", tools.leave_work),  # leave_work는 마지막에 (리셋되므로)
    ]

    for tool_name, tool_func in all_tools:
        print(f"\n[{tool_name}] 호출 중...")
        response = await tool_func(state_manager)
        assert response is not None, f"{tool_name} returned None"
        assert "Stress Level:" in response, f"{tool_name} missing Stress Level"
        assert "Boss Alert Level:" in response, f"{tool_name} missing Boss Alert Level"
        print(f"[{tool_name}] ✓ 성공")
        print(f"현재 상태: Stress={state_manager.stress_level}, Boss Alert={state_manager.boss_alert_level}")

Comment on lines +122 to +127
start_time = time.time()
response = await tools.take_a_break(state_manager)
elapsed_time = time.time() - start_time

print(f"경과 시간: {elapsed_time:.2f}초")
assert elapsed_time >= 20.0, f"Expected 20 second delay, got {elapsed_time:.2f} seconds"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

이 테스트는 실제 시간 지연(time.time()asyncio.sleep)에 의존하여 20초 지연을 확인합니다. 이로 인해 테스트 실행 시간이 길어지고 CI/CD 환경에서 불안정해질 수 있습니다. asyncio.sleep을 모의(mock)하거나 freezegun과 같은 시간 모의 라이브러리를 사용하여 실제 대기 시간 없이 시간의 흐름을 시뮬레이션하는 것을 고려해 보세요. 이렇게 하면 테스트가 훨씬 빠르고 결정적으로 실행됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant