Skip to content

Conversation

yuji38kwmt
Copy link
Collaborator

@yuji38kwmt yuji38kwmt commented Jan 23, 2025

Annofabのswagger.yamlの定義が間違っているため、いくつかのエラーが発生する。
それまでdraftモードにする。

@yuji38kwmt yuji38kwmt changed the title update test pydanticのテストコードを追加 Jan 23, 2025
@yuji38kwmt yuji38kwmt marked this pull request as draft January 23, 2025 06:55
@yuji38kwmt yuji38kwmt requested a review from Copilot August 25, 2025 04:36
@yuji38kwmt yuji38kwmt marked this pull request as ready for review August 25, 2025 04:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds test code for pydantic models, specifically adding a test for TaskHistory and commenting out a test for Comment due to incorrect swagger.yaml definitions that cause errors.

  • Adds a new test function test__TaskHistory() to verify TaskHistory model functionality
  • Comments out the test__Comment() function due to swagger.yaml definition issues
  • Imports the TaskHistory model to support the new test

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +44 to +45
# swagger.yamlの定義が間違っているためエラーが発生する
# swagger.yamlの定義が修正されるまでコメントアウトする
Copy link
Preview

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment explains why the test is commented out, but it would be more helpful to include a reference to a tracking issue or ticket for when this will be fixed.

Suggested change
# swagger.yamlの定義が間違っているためエラーが発生する
# swagger.yamlの定義が修正されるまでコメントアウトする
# swagger.yamlの定義が修正されるまでコメントアウトする
# Tracking issue: https://github.com/your-org/your-repo/issues/1234

Copilot uses AI. Check for mistakes.

@kci-pr-agent
Copy link

kci-pr-agent bot commented Aug 25, 2025

Title

pydanticのテストコードを追加


Description

  • TaskHistoryモデルのインポートとテストを追加

  • swagger.yaml誤りによりCommentテストを一時無効化


Changes walkthrough 📝

Relevant files
Tests
test_pydantic_models.py
TaskHistoryテスト追加とCommentテスト無効化                                                     

tests/test_pydantic_models.py

  • TaskHistoryモデルのインポート追加
  • test__TaskHistory関数を追加
  • test__Comment関数をコメントアウト
  • +16/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @kci-pr-agent
    Copy link

    kci-pr-agent bot commented Aug 25, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Assertions不足

    新規追加のテスト(test__TaskHistory)では結果の型や属性を検証しておらず、単にメソッド呼び出しを行うのみです。適切なアサーションを追加して、生成されたオブジェクトが期待される値や構造を持つことを検証してください。

    def test__TaskHistory():
        content, _ = service.api.get_task_histories(project_id, task_id)
        TaskHistory.from_dict(content[0])
    未定義変数の検証

    serviceproject_idtask_idがテスト内で使用されていますが、定義箇所が見当たりません。フィクスチャやグローバル変数の定義が適切に含まれているか確認してください。

    def test__Task():
        content, _ = service.api.get_tasks(project_id)
        task = content["list"][0]
        Task.from_dict(task)
    
    
    def test__TaskHistory():
        content, _ = service.api.get_task_histories(project_id, task_id)
        TaskHistory.from_dict(content[0])
    コメントアウトされたテスト

    Commentモデルのテストがswagger定義の問題でコメントアウトされています。swagger修正後の対応をTODOやissueで追跡し、再有効化する計画をドキュメント化してください。

    # swagger.yamlの定義が間違っているためエラーが発生する
    # swagger.yamlの定義が修正されるまでコメントアウトする
    # def test__Comment():
    #     with tempfile.NamedTemporaryFile() as temp_file:
    #         service.wrapper.download_project_comments_url(project_id, temp_file.name)
    #         with open(temp_file.name) as f:
    #             comments = json.load(f)
    #     Comment.from_dict(comments[0])

    Comment on lines +39 to +41
    def test__TaskHistory():
    content, _ = service.api.get_task_histories(project_id, task_id)
    TaskHistory.from_dict(content[0])
    Copy link

    Choose a reason for hiding this comment

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

    Suggestion: レスポンスのデータ構造に合わせてリストを取得し、要素が存在することをassertで検証してください。また、from_dictの戻り値がTaskHistoryインスタンスであることをチェックすると、テストの信頼性が向上します。 [possible issue, importance: 6]

    Suggested change
    def test__TaskHistory():
    content, _ = service.api.get_task_histories(project_id, task_id)
    TaskHistory.from_dict(content[0])
    def test__TaskHistory():
    content, _ = service.api.get_task_histories(project_id, task_id)
    assert content.get("list"), "タスク履歴が返却されていません"
    history = TaskHistory.from_dict(content["list"][0])
    assert isinstance(history, TaskHistory)

    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