Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests #571

Merged
merged 31 commits into from
Jan 27, 2025
Merged

Add more tests #571

merged 31 commits into from
Jan 27, 2025

Conversation

MatthewMckee4
Copy link
Member

@MatthewMckee4 MatthewMckee4 commented Jan 25, 2025

Summary by Sourcery

Tests:

  • Added tests for the show command in the CLI.

Copy link
Contributor

sourcery-ai bot commented Jan 25, 2025

Reviewer's Guide by Sourcery

This pull request adds tests for the kfactory CLI. It includes tests for the version callback and the show command. The tests cover cases with existing files, non-existent files, directories, and files with no permissions.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added tests for the kfactory CLI.
  • Added a test for the version callback.
  • Added a test for the show command.
  • The show command test covers cases with existing files, non-existent files, directories, and files with no permissions.
tests/cli/test_cli.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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@github-actions github-actions bot added the enhancement New feature or request label Jan 25, 2025
@github-actions github-actions bot added the github_actions Pull requests that update GitHub Actions code label Jan 26, 2025
Copy link

codecov bot commented Jan 26, 2025

Codecov Report

Attention: Patch coverage is 66.20690% with 49 lines in your changes missing coverage. Please review.

Project coverage is 60.75%. Comparing base (5a2a063) to head (21ec21f).
Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
src/kfactory/kcell.py 66.20% 37 Missing and 12 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #571      +/-   ##
==========================================
+ Coverage   59.30%   60.75%   +1.44%     
==========================================
  Files          49       49              
  Lines        9160     9185      +25     
  Branches     1739     1735       -4     
==========================================
+ Hits         5432     5580     +148     
+ Misses       3196     3085     -111     
+ Partials      532      520      -12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MatthewMckee4 MatthewMckee4 marked this pull request as ready for review January 27, 2025 14:38
Copy link
Contributor

@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.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

for p1 in (True, False)
for p2 in (True, False)
],
smart_bundle_routing_params,
)
def test_smart_routing(
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Low code quality found in test_smart_routing - 7% (low-code-quality)


ExplanationThe quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

assert valid_data.key3 == [1, 2, 3]

with pytest.raises(ValidationError):
Info(key1=set([1, 2, 3]))
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Unwrap a constant iterable constructor (unwrap-iterable-construction)

Suggested change
Info(key1=set([1, 2, 3]))
Info(key1={1, 2, 3})

assert check_metadata_type({"key": "value"}) == {"key": "value"}

with pytest.raises(ValueError):
check_metadata_type(set([1, 2, 3])) # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (code-quality): Unwrap a constant iterable constructor (unwrap-iterable-construction)

Suggested change
check_metadata_type(set([1, 2, 3])) # type: ignore
check_metadata_type({1, 2, 3})

@sebastian-goeldi sebastian-goeldi merged commit f3f62db into main Jan 27, 2025
16 checks passed
@sebastian-goeldi sebastian-goeldi deleted the add-tests branch January 27, 2025 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants