From e65fe597316a3d69f532b64e8748bb631d5ccc38 Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Thu, 21 Nov 2024 20:00:12 -0700 Subject: [PATCH] Remove unused test module and add small check for eic --- tests/conftest.py | 2 +- tests/integration/test_review_model.py | 59 ++++++++++++++------------ tests/unit/test_github_api.py | 6 +-- tests/unit/test_update_review_teams.py | 9 ---- 4 files changed, 37 insertions(+), 39 deletions(-) delete mode 100644 tests/unit/test_update_review_teams.py diff --git a/tests/conftest.py b/tests/conftest.py index c79a3ea..e484968 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,7 +13,7 @@ @pytest.fixture def ghuser_response(): - """This is the initial github response. I changed the username to + """This is the initial GitHub response. I changed the username to create this object""" expected_response = { "login": "chayadecacao", diff --git a/tests/integration/test_review_model.py b/tests/integration/test_review_model.py index 5ea2af3..b3a4434 100644 --- a/tests/integration/test_review_model.py +++ b/tests/integration/test_review_model.py @@ -1,36 +1,43 @@ +import pytest + from pyosmeta.models import ReviewModel + # We could setup some example data using fixtures and a conf.py # Once we have a better view of the test suite. -example = { - "submitting_author": { - "github_username": "nabobalis", - "name": "Nabil Freij", - }, - "all_current_maintainers": [], - "package_name": "sunpy", - "one-line_description_of_package": "Python for Solar Physics", - "repository_link": "https://github.com/sunpy/sunpy", - "version_submitted": "5.0.1", - "editor": {"github_username": "cmarmo", "name": ""}, - "reviewer_1": {"github_username": "Septaris", "name": ""}, - "reviewer_2": {"github_username": "nutjob4life", "name": ""}, - "archive": "[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8384174.svg)](https://doi.org/10.5281/zenodo.8384174)", - "version_accepted": "5.1.1", - "joss_doi": "[![DOI](https://joss.theoj.org/papers/10.21105/joss.01832/status.svg)](https://joss.theoj.org/papers/10.21105/joss.01832)", - "date_accepted": "01/18/2024", - "categories": [ - "data-retrieval", - "data-extraction", - "data-processing/munging", - "data-visualization", - ], -} +@pytest.fixture +def review_data(): + return { + "submitting_author": { + "github_username": "nabobalis", + "name": "Nabil Freij", + }, + "all_current_maintainers": [], + "package_name": "sunpy", + "one-line_description_of_package": "Python for Solar Physics", + "repository_link": "https://github.com/sunpy/sunpy", + "version_submitted": "5.0.1", + "eic": {"github_username": "cmarmo", "name": ""}, + "editor": {"github_username": "cmarmo", "name": ""}, + "reviewer_1": {"github_username": "Septaris", "name": ""}, + "reviewer_2": {"github_username": "nutjob4life", "name": ""}, + "archive": "[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8384174.svg)](https://doi.org/10.5281/zenodo.8384174)", + "version_accepted": "5.1.1", + "joss_doi": "[![DOI](https://joss.theoj.org/papers/10.21105/joss.01832/status.svg)](https://joss.theoj.org/papers/10.21105/joss.01832)", + "date_accepted": "01/18/2024", + "categories": [ + "data-retrieval", + "data-extraction", + "data-processing/munging", + "data-visualization", + ], + } -def test_alias_choices_validation(): +def test_alias_choices_validation(review_data): """Test that model correctly recognizes the field alias""" - new = ReviewModel(**example) + new = ReviewModel(**review_data) assert new.date_accepted == "2024-01-18" assert new.package_description == "Python for Solar Physics" + assert new.eic.github_username == "cmarmo" diff --git a/tests/unit/test_github_api.py b/tests/unit/test_github_api.py index 445a9ee..3576d20 100644 --- a/tests/unit/test_github_api.py +++ b/tests/unit/test_github_api.py @@ -147,21 +147,21 @@ def test_api_endpoint_with_invalid_dates(after_date, expected_url): def test_get_user_info_successful(mocker, ghuser_response): """Test that an expected response returns properly""" - expected_response = ghuser_response mock_response = mocker.Mock() mock_response.status_code = 200 - mock_response.json.return_value = expected_response + mock_response.json.return_value = ghuser_response mocker.patch("requests.get", return_value=mock_response) github_api_instance = GitHubAPI() user_info = github_api_instance.get_user_info("example_user") - assert user_info == expected_response + assert user_info == ghuser_response def test_get_user_info_bad_credentials(mocker): """Test that a value error is raised when the GH token is not valid.""" + mock_response = mocker.Mock() mock_response.status_code = 401 mocker.patch("requests.get", return_value=mock_response) diff --git a/tests/unit/test_update_review_teams.py b/tests/unit/test_update_review_teams.py deleted file mode 100644 index 5cff40b..0000000 --- a/tests/unit/test_update_review_teams.py +++ /dev/null @@ -1,9 +0,0 @@ -def get_clean_user(username: str) -> str: - """A small helper that removes whitespace and ensures username is - lower case""" - # If the github username has spaces there is an error which might be - # that someone added a name after the username. Only return the github - # username - if len(username.split()) > 1: - username = username.split()[0] - return username.lower().strip()