-
Notifications
You must be signed in to change notification settings - Fork 7
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
added change to tasks file and all tests #106
Conversation
actions/setup-python#672 The motivation for the changes |
To update the tests to
Should become:
|
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.
Overall looks good. Just a couple of formatting things and the update to the github action.
ADSOrcid/tasks.py
Outdated
cl = updater.update_record(rec, claim, app.conf.get('MIN_LEVENSHTEIN_RATIO', 0.9)) | ||
cl = updater.update_record(rec, claim, app.conf.get("MIN_LEVENSHTEIN_RATIO", 0.9)) | ||
unique_bibs = list(set([bibcode] + identifiers)) | ||
status = "verified" if cl else "rejected" |
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.
This works, I would just recommend rewriting it as
if ...
else ...
to make it a little more readable
requirements.txt
Outdated
numpy==1.16.6 | ||
matplotlib==2.0.2 | ||
numpy==1.22 # 1.16.6 is not compatible with M1. | ||
matplotlib==3.5.0 #2.0.2 is not compatible with Python 3.8 |
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.
Both of these make sense, I would just delete the comments before merging.
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.
Yup. Thanks for the reminder. Done!
ADSOrcid/tasks.py
Outdated
cl = updater.update_record(rec, claim, app.conf.get("MIN_LEVENSHTEIN_RATIO", 0.9)) | ||
unique_bibs = list(set([bibcode] + identifiers)) | ||
status = "verified" if cl else "rejected" | ||
r = app.client.post( |
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.
I would either move this post down to the checks on r.status_code
and r.json()
or move the checks up to be the next call after this post so that way all the code related to the post to ORCID service is in one spot.
ADSOrcid/tests/test_tasks.py
Outdated
def test_match_claim_unknown_payload_should_return_warning(self): | ||
with pytest.raises(ProcessingException) as exception_info: | ||
tasks.task_match_claim([]) | ||
assert str(exception_info.value) == "Received unknown payload []" |
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.
in general we use the self.assertX
methods provided by TestCase
for checking the output of tests. There's nothing wrong with assert
. It's more a consistency thing.
ADSOrcid/tests/test_tasks.py
Outdated
} | ||
with pytest.raises(ProcessingException) as exception_info: | ||
tasks.task_match_claim(claim) | ||
assert str( |
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.
same here with assert
vs self.assertEqual()
ADSOrcid/tests/test_tasks.py
Outdated
assert "id2" in warning_message | ||
assert "BIBCODE22" in warning_message | ||
assert "0000-0003-3041-2092" in warning_message | ||
assert "does not match input" in warning_message |
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.
All these tests look good. I would just unify the assertions to all use TestCase.assertX
b54ed38
to
7b86803
Compare
…ld_return_rejected
…_should_return_does_not_match
…turn_rejected back
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.
This looks good to me. Just one incredibly small potential tweak in tasks.py
and then one potential test tweak. It looks like one of the assert methods used in the tests for models.py
has been deprecated. Would you be willing to incorporate that fix into this PR?
One of the offending lines (it looks like there might be two of them in total):
ADSOrcid/tests/test_models.py::Test::test_models
/home/runner/work/ADSOrcid/ADSOrcid/ADSOrcid/tests/test_models.py:61: DeprecationWarning: Please use assertRaisesRegex instead.
with self.assertRaisesRegexp(Exception, 'IntegrityError'):
ADSOrcid/tasks.py
Outdated
cl = updater.update_record(rec, claim, app.conf.get('MIN_LEVENSHTEIN_RATIO', 0.9)) | ||
cl = updater.update_record(rec, claim, app.conf.get("MIN_LEVENSHTEIN_RATIO", 0.9)) | ||
unique_bibs = list(set([bibcode] + identifiers)) | ||
status = "verified" |
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.
This is a really small thing, but you could tuck this into the if cl:
to be consistent with the else
No description provided.