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

feat: Increase coverage. #484

Merged
merged 7 commits into from
Mar 27, 2023
Merged

Conversation

terjekv
Copy link
Collaborator

@terjekv terjekv commented Mar 17, 2023

Eventually fixes #483

First pass:

  • Add pragma to exempt lines from coverage to .coveragerc
  • Add test for stringifying HostPolicyComponent-based objects (see Stringify in HostPolicyComponent returns quoted string. #482)
  • Mock host_permissions/user_in_required_groups as its not supported by default.
  • Ensure that IsSuperOrAdminOrReadOnly is tested for unauthenticated users (test_permissions/test_get_at_different_privilege_levels)
  • Exclude exceptions from coverage that are impossible to reach without creating a broken API.
  • Test that IsSuperOrNetworkAdminMember returns 401 for unauthenticated users (test_networks/test_networks_get_401_unauthorized).

Fixes unioslo#483

First pass:
  - Add pragma to exempt lines from coverage to .coveragerc
  - Add test for stringifying HostPolicyComponent-based objects (see unioslo#482)
  - Mock host_permissions/user_in_required_groups as its not supported by default.
  - Ensure that IsSuperOrAdminOrReadOnly is tested for unauthenticated users (test_permissions/test_get_at_different_privilege_levels)
  - Exclude exceptions from coverage that are impossible to reach without creating a broken API.
  - Test that IsSuperOrNetworkAdminMember returns 401 for unauthenticated users (test_networks/test_networks_get_401_unauthorized).
@coveralls
Copy link
Collaborator

coveralls commented Mar 17, 2023

Coverage Status

Coverage: 98.864% (+0.6%) from 98.286% when pulling 42d2e44 on terjekv:terjekv/issue483 into b09877b on unioslo:master.

  - Pragma out more unreachable code paths.
  - Some of these code paths should to be reworked to ensure that production doesn't rely on them.
  - Pragma out skipped tests.
  - Added tests for conflicting labels and IDNA errors.
  - Added tests for some internal and previous untested code.
@unioslo unioslo deleted a comment from coveralls Mar 21, 2023
@terjekv
Copy link
Collaborator Author

terjekv commented Mar 22, 2023

The next steps is to test https://github.com/unioslo/mreg/blob/master/mreg/signals.py and https://github.com/unioslo/mreg/blob/master/mreg/mqsender.py. There is no need to take that work into this PR. Opening for review.

@terjekv terjekv marked this pull request as ready for review March 22, 2023 06:48
@terjekv terjekv requested a review from oyvindhagberg March 22, 2023 06:48
@oyvindkolbu oyvindkolbu self-requested a review March 22, 2023 07:39
Copy link
Collaborator

@oyvindkolbu oyvindkolbu left a comment

Choose a reason for hiding this comment

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

Some tiny adjustments needed. Mostly justifying pragmas.

hostpolicy/tests.py Outdated Show resolved Hide resolved
mreg/api/permissions.py Outdated Show resolved Hide resolved
mreg/api/permissions.py Outdated Show resolved Hide resolved
mreg/api/v1/history.py Outdated Show resolved Hide resolved
mreg/api/v1/serializers.py Outdated Show resolved Hide resolved
mreg/models.py Outdated Show resolved Hide resolved
mreg/api/v1/tests/tests_zones.py Show resolved Hide resolved
mreg/api/v1/tests/tests.py Outdated Show resolved Hide resolved
mreg/signals.py Outdated Show resolved Hide resolved
mreg/signals.py Outdated Show resolved Hide resolved
  - Test add_user_to_groups (limited scope)
  - Remove some overzealous  pragmas.
  - Add comments for skipped tests.
Copy link
Contributor

@oyvindhagberg oyvindhagberg left a comment

Choose a reason for hiding this comment

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

👍 💯 :shipit:

@oyvindhagberg oyvindhagberg merged commit c14cd9d into unioslo:master Mar 27, 2023
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.

Increase coverage.
4 participants