Skip to content

Coverage to 85%#48

Merged
mshriver merged 3 commits intoibutsu:mainfrom
mshriver:final-coverage
Nov 24, 2025
Merged

Coverage to 85%#48
mshriver merged 3 commits intoibutsu:mainfrom
mshriver:final-coverage

Conversation

@mshriver
Copy link
Contributor

@mshriver mshriver commented Nov 24, 2025

Move API module test coverage to pytest.

implement coverage for all the stubs.

Summary by Sourcery

Improve test coverage for multiple Ibutsu client APIs using pytest-based tests and shared test data factories.

Tests:

  • Add reusable pytest fixtures for realistic sample entities and pagination data used across API tests.
  • Replace placeholder unittest stubs with comprehensive pytest tests for login, user, admin user management, group, widget, widget configuration, import, and task APIs, covering success, error, authentication, and *_with_http_info flows.

Copilot AI review requested due to automatic review settings November 24, 2025 18:51
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 24, 2025

Reviewer's Guide

Adds comprehensive pytest-based coverage for multiple ibutsu_client API modules, introducing reusable test data factory fixtures and replacing minimal unittest stubs with detailed success and error-path tests that mock api_client.call_api and validate both standard and *_with_http_info endpoints.

File-Level Changes

Change Details Files
Introduce reusable pytest fixtures for realistic API entity test data and pagination metadata.
  • Add factory-style fixtures to generate sample data for projects, runs, results, artifacts, users, dashboards, widgets, groups, tokens, and pagination structures
  • Standardize use of uuid-based IDs and default fields to keep tests concise but realistic
  • Centralize sample data generation to reduce duplication across API test modules
test/conftest.py
Convert LoginApi tests from unittest stubs to comprehensive pytest tests that cover success and failure scenarios.
  • Replace unittest.TestCase-based TestLoginApi with a plain pytest class
  • Mock api.api_client.call_api using pytest-mock to simulate 2xx/3xx/4xx/5xx responses via create_mock_response
  • Assert proper behavior and model deserialization for activate/auth/config/login/recover/register/reset_password/support methods and their *_with_http_info variants
  • Verify correct exception raising for NotFoundException, ServiceException, and generic auth/validation failures based on HTTP status codes
test/test_login_api.py
Expand WidgetConfigApi, AdminUserManagementApi, UserApi, GroupApi, ImportApi, TaskApi, and WidgetApi tests to fully exercise CRUD/list/status and widget endpoints using pytest.
  • Replace empty or stubbed unittest-based test classes with pytest classes containing real tests for each public API method
  • Use create_mock_response and mocker.patch.object(api.api_client, 'call_api', ...) to drive different HTTP status paths (success, not found, unauthorized/forbidden, conflict, server error)
  • Validate returned model instances (WidgetConfig, WidgetConfigList, User, UserList, Token, TokenList, Group, GroupList, ModelImport, WidgetTypeList) and raw dict responses where appropriate (TaskApi, WidgetApi.get_widget)
  • Add separate *_with_http_info tests asserting HTTP status_code and type of data payload, ensuring coverage of both shorthand and detailed response APIs
test/test_widget_config_api.py
test/test_admin_user_management_api.py
test/test_user_api.py
test/test_group_api.py
test/test_import_api.py
test/test_task_api.py
test/test_widget_api.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

New security issues found

Copy link

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 migrates API module test coverage from unittest to pytest and implements comprehensive test coverage to reach 85% coverage. The migration includes replacing unittest.TestCase classes with pytest-style test classes and adding extensive test cases for success paths, error conditions, and HTTP status code handling.

Key Changes:

  • Migration from unittest to pytest framework across 8 API test modules
  • Addition of comprehensive test data factory fixtures in conftest.py
  • Expanded test coverage including success cases, error handling, and _with_http_info method variants

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
test/conftest.py Added factory fixtures for generating sample test data (projects, runs, results, artifacts, pagination, users, dashboards, widget configs, groups, tokens)
test/test_widget_config_api.py Migrated to pytest; added 17 comprehensive test cases covering CRUD operations, error handling, and HTTP status codes
test/test_widget_api.py Migrated to pytest; added 12 test cases covering widget data generation and widget types with various parameters
test/test_user_api.py Migrated to pytest; added 16 test cases covering token and user management operations
test/test_task_api.py Migrated to pytest; added 11 test cases covering task status monitoring (pending, running, completed, failed)
test/test_login_api.py Migrated to pytest; added 20 test cases covering authentication, registration, password recovery, and login configuration
test/test_import_api.py Migrated to pytest; added 13 test cases covering file import operations with JUnit and Ibutsu archive formats
test/test_group_api.py Migrated to pytest; added 13 test cases covering group CRUD operations with pagination and filtering
test/test_admin_user_management_api.py Migrated to pytest; added 16 test cases covering admin-level user management operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mshriver mshriver force-pushed the final-coverage branch 2 times, most recently from d872afc to 29b2e14 Compare November 24, 2025 21:41
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.57%. Comparing base (7d61f7d) to head (9c20c02).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #48       +/-   ##
===========================================
+ Coverage   68.68%   84.57%   +15.88%     
===========================================
  Files          58       58               
  Lines        4783     4783               
  Branches      496      496               
===========================================
+ Hits         3285     4045      +760     
+ Misses       1338      496      -842     
- Partials      160      242       +82     
Flag Coverage Δ
unittests 84.57% <ø> (+15.88%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d61f7d...9c20c02. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Use sample_* functions to provide data during parametrization into the
mock_response fixture
@mshriver mshriver merged commit 2ec1553 into ibutsu:main Nov 24, 2025
8 checks passed
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.

2 participants