openml / server-api

Python-based server
https://openml.github.io/server-api/
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Maint/tests #204

Closed PGijsbers closed 5 days ago

PGijsbers commented 5 days ago

Summary by Sourcery

Refactor tests to improve performance by replacing some integration tests with lighter versions and introduce verified user constants. Add documentation on using fixtures and mocks in tests to guide developers in writing efficient tests.

New Features:

Enhancements:

Documentation:

Tests:

sourcery-ai[bot] commented 5 days ago

Reviewer's Guide by Sourcery

This pull request focuses on improving the test suite by adding documentation on using fixtures and mocks, replacing some integration-style tests with lighter versions, and adding verified user constants. The changes aim to enhance test performance and provide guidance for writing more efficient tests.

Class diagram for User and UserGroup

classDiagram
    class User {
        int user_id
        Connection _database
        List~UserGroup~ _groups
    }
    class UserGroup {
        <<enumeration>>
        ADMIN
        READ_WRITE
    }
    User --> UserGroup : has
    note for User "Represents a user with associated groups and database connection"

Class diagram for ApiKey

classDiagram
    class ApiKey {
        <<enumeration>>
        ADMIN
        REGULAR_USER
        OWNER_USER
        INVALID
    }
    note for ApiKey "Represents different types of API keys as string enumerations"

File-Level Changes

Change Details Files
Added documentation on using fixtures and mocks in tests
  • Created a new file with detailed explanations on test writing best practices
  • Included a comparison of different fixture overheads
  • Provided guidance on when to use mocks vs. database fixtures
  • Added examples of how to implement mocks in tests
docs/contributing/tests.md
mkdocs.yml
Replaced integration-style tests with lighter versions
  • Refactored test_private_dataset_no_user_no_access to use direct function calls instead of API requests
  • Updated test_private_dataset_owner_access to use function calls and database fixtures instead of API requests
  • Removed skipped test cases that were waiting for API key implementation
tests/routers/openml/datasets_test.py
Added verified user constants and refactored user-related code
  • Created constants for different user types (NO_USER, SOME_USER, OWNER_USER, ADMIN_USER)
  • Moved ApiKey enum from conftest.py to users_test.py
  • Added tests to verify user fetching with different API keys
tests/routers/openml/users_test.py
tests/conftest.py
tests/routers/openml/datasets_list_datasets_test.py

Possibly linked issues


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. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a 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. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) 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 - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
codecov[bot] commented 5 days ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Please upload report for BASE (main@dd9682c). Learn more about missing BASE report.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #204 +/- ## ======================================= Coverage ? 92.19% ======================================= Files ? 51 Lines ? 1844 Branches ? 144 ======================================= Hits ? 1700 Misses ? 102 Partials ? 42 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.