-
Notifications
You must be signed in to change notification settings - Fork 0
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
More tests for local.py #70
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Reviewed everything up to 42be47c in 1 minute and 3 seconds
More details
- Looked at
57
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
7
drafted comments based on config settings.
1. tests/test_local.py:58
- Draft comment:
The comment is unnecessary as the test name is self-explanatory. Consider removing it. - Reason this comment was not posted:
Confidence changes required:10%
The test functiontest_clean_up_tmp_file_none_does_not_raise
is correctly testing that passingNone
toclean_up_tmp_file
does not raise an error. However, the comment is unnecessary as the test name is self-explanatory.
2. tests/test_local.py:62
- Draft comment:
Good use ofpytest.raises
to test forFileNotFoundError
. - Reason this comment was not posted:
Confidence changes required:0%
The test functiontest_get_file_hash_file_not_found
correctly tests that aFileNotFoundError
is raised when a non-existent file is passed toget_file_hash
. The test is well-structured and clear.
3. tests/test_local.py:66
- Draft comment:
Good test for handling empty files inget_file_hash
. - Reason this comment was not posted:
Confidence changes required:0%
The test functiontest_get_file_hash_empty_file
is correctly testing the hash of an empty file. The test is well-structured and clear.
4. tests/test_local.py:73
- Draft comment:
Good use ofunittest.mock.patch
to mockmagic.from_file
. - Reason this comment was not posted:
Confidence changes required:0%
The test functiontest_get_content_type_magic_called
usesunittest.mock.patch
to mockmagic.from_file
. This is a good practice to isolate the test from external dependencies.
5. tests/test_local.py:83
- Draft comment:
Good use ofpytest.raises
to test forFileNotFoundError
. - Reason this comment was not posted:
Confidence changes required:0%
The test functiontest_get_content_type_file_not_found
correctly tests that aFileNotFoundError
is raised when a non-existent file is passed toget_content_type
. The test is well-structured and clear.
6. tests/test_local.py:87
- Draft comment:
Good test for handling empty strings inget_bytes_hash
. - Reason this comment was not posted:
Confidence changes required:0%
The test functiontest_get_bytes_hash_empty_string
is correctly testing the hash of an empty string. The test is well-structured and clear.
7. tests/test_local.py:1
- Draft comment:
Ensure no hardcoded API keys are present in the code. This file is clear of such issues. - Reason this comment was not posted:
Confidence changes required:0%
The code does not contain any hardcoded API keys, so it adheres to the rule about not hardcoding API keys in the source code.
Workflow ID: wflow_SXquJTkRilfJNLrm
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good to me! Incremental review on cfd00c3 in 21 seconds
More details
- Looked at
33
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. tests/test_local.py:35
- Draft comment:
The use ofusedforsecurity=False
inhashlib.sha1
is appropriate here since SHA-1 is not recommended for security purposes. This is consistent with its usage in other parts of the code. - Reason this comment was not posted:
Confidence changes required:0%
The use ofusedforsecurity=False
inhashlib.sha1
is not necessary for non-security purposes, but it is a good practice to explicitly state it when using SHA-1, which is considered weak for security purposes. This is consistent across multiple instances in the code.
Workflow ID: wflow_1rmY15jaLBgG9mYV
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Important
Add tests to
test_local.py
for edge cases and improve coverage, including file not found and empty file scenarios.test_clean_up_tmp_file_none_does_not_raise
: Ensuresclean_up_tmp_file
does not raise errors withNone
.test_get_file_hash_file_not_found
: Checksget_file_hash
raisesFileNotFoundError
for non-existent files.test_get_file_hash_empty_file
: Verifiesget_file_hash
returns correct hash for empty files.test_get_content_type_magic_called
: Usesunittest.mock.patch
to ensuremagic.from_file
is called correctly.test_get_content_type_file_not_found
: Ensuresget_content_type
raisesFileNotFoundError
for non-existent files.test_get_bytes_hash_empty_string
: Verifiesget_bytes_hash
returns correct hash for empty strings.print
statement insetup_and_teardown_temp_dir
.This description was created by for cfd00c3. It will automatically update as commits are pushed.