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

added change to tasks file and all tests #106

Merged
merged 34 commits into from
Jul 28, 2023
Merged

Conversation

femalves
Copy link
Contributor

No description provided.

@femalves
Copy link
Contributor Author

actions/setup-python#672
"Breaking changes
Hello everyone. The Python 2.7.x will be removed from python-versions and it won't be possible to set up Python 2.7.x by setup-python.

The motivation for the changes
Python2.7 is not supported since January 1, 2020."

@femalves femalves requested a review from tjacovich July 18, 2023 16:50
@tjacovich
Copy link

tjacovich commented Jul 18, 2023

To update the tests to python3
This section in the python_actions.yaml file

  steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-python@v2
      with:
        python-version: 2.7

Should become:

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: "3.8"

Copy link

@tjacovich tjacovich left a 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.

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"

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

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.

Copy link
Contributor Author

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!

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(

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.

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 []"

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.

}
with pytest.raises(ProcessingException) as exception_info:
tasks.task_match_claim(claim)
assert str(

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()

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

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

@femalves femalves requested a review from tjacovich July 24, 2023 18:24
Copy link

@tjacovich tjacovich left a 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'):

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"

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

@tjacovich tjacovich linked an issue Jul 28, 2023 that may be closed by this pull request
@femalves femalves merged commit d2d71ac into master Jul 28, 2023
2 checks passed
@femalves femalves deleted the dev_status_reject_bug branch January 10, 2024 17:29
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.

Update status to "rejected" if claim is rejected
2 participants