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 model tests #134

Draft
wants to merge 16 commits into
base: dev
Choose a base branch
from
Draft

Add model tests #134

wants to merge 16 commits into from

Conversation

ryanmerolle
Copy link
Collaborator

Pull Request

Related Issue

Closes #47
Closes #133

New Behavior

  • Adds tests to models.
  • Addresses a bug found in the AccessList model discovered while adding tests.

Contrast to Current Behavior

No tests for models
A bug does not allow hyphens in access-list names

Discussion: Benefits and Drawbacks

...

Changes to the Documentation

...

Proposed Release Note Entry

...

Double Check

  • I have explained my PR according to the information in the comments
    or in a linked issue.
  • My PR targets the dev branch.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 2, 2023

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.78%.

Quality metrics Before After Change
Complexity 11.01 🙂 10.74 🙂 -0.27 👍
Method Length 106.73 🙂 105.04 🙂 -1.69 👍
Working memory 8.86 🙂 8.76 🙂 -0.10 👍
Quality 57.62% 🙂 58.40% 🙂 0.78% 👍
Other metrics Before After Change
Lines 755 768 13
Changed files Quality Before Quality After Quality Change
netbox_acls/forms/models.py 48.09% 😞 48.09% 😞 0.00%
netbox_acls/graphql/schema.py 86.70% ⭐ 86.70% ⭐ 0.00%
netbox_acls/graphql/types.py 72.73% 🙂 72.73% 🙂 0.00%
netbox_acls/migrations/0002_alter_accesslist_options_and_more.py 61.79% 🙂 61.79% 🙂 0.00%
netbox_acls/migrations/0003_netbox_acls.py 75.10% ⭐ 75.10% ⭐ 0.00%
netbox_acls/models/access_lists.py 94.10% ⭐ 90.78% ⭐ -3.32% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
netbox_acls/forms/models.py ACLInterfaceAssignmentForm.clean 15 🙂 282 ⛔ 15 😞 31.91% 😞 Try splitting into smaller methods. Extract out complex expressions
netbox_acls/forms/models.py AccessListForm.clean 21 😞 236 ⛔ 13 😞 32.23% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
netbox_acls/forms/models.py AccessListForm.__init__ 27 😞 194 😞 8 🙂 40.82% 😞 Refactor to reduce nesting. Try splitting into smaller methods
netbox_acls/forms/models.py ACLExtendedRuleForm.clean 15 🙂 121 😞 6 ⭐ 61.28% 🙂 Try splitting into smaller methods

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@ryanmerolle ryanmerolle self-assigned this Feb 2, 2023
@ryanmerolle ryanmerolle marked this pull request as draft February 2, 2023 22:52
@ryanmerolle
Copy link
Collaborator Author

@abhi1693 as discussed, I started pulling out the various fixes from my enormous branch.

This PR will focus on tests for models and any bugs in the model it may uncover.

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 1 Security Hotspot
Code Smell A 24 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

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.

[Housekeeping]: Develop Plugin Tests - Models [Bug]: AccessList RegexValidator not allowing hyphens
2 participants