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

Convert unittest to pytest #3622

Merged
merged 12 commits into from Jan 11, 2024
Merged

Conversation

ngken0995
Copy link
Collaborator

@ngken0995 ngken0995 commented Jan 3, 2024

Fixes

Fixes #3425 by @AetherUnbound

Description

On catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py, setUp function is renamed to setup_pool, set_pool will have a parameter sample_pool_fixture retrieved from conftest.TestExternalDAGsSensor class will be removed and all test function will be in the same module.

On ingestion_server/test/integration_test.py, setUpClass is rename to setup_fixture, setup_fixture use scope as module, autouse is set as True and it will return a dictionary for other function to retrieve them. Install pytest-subtests to replace unittest subTest.

Testing Instructions

For catalog:

run just catalog/test

For ingestion server:

source ingestion_server/venv/bin/activate
pipenv install --dev
just ingestion_server/test_local

if ingestion server fail:

run just ingestion_server/test-clean-dc
run just ingestion_server/test_local

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • [N/A] I added or updated tests for the changes I made (if applicable).
  • [N/A] I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • [N/A] I ran the DAG documentation generator (if applicable).

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@ngken0995 ngken0995 requested review from a team as code owners January 3, 2024 20:13
@github-actions github-actions bot added 🧱 stack: catalog Related to the catalog and Airflow DAGs 🧱 stack: ingestion server Related to the ingestion/data refresh server labels Jan 3, 2024
@openverse-bot openverse-bot added 🟩 priority: low Low priority and doesn't need to be rushed 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🤖 aspect: dx Concerns developers' experience with the codebase labels Jan 3, 2024
Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

Looks really good to me, I just have a couple questions for clarification, but nothing is necessarily a blocker 👍

ingestion_server/test/integration_test.py Outdated Show resolved Hide resolved
data.
"""

es = _get_es()
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe _get_es could also be converted to a fixture? It's used as such, but I don't know what the specific benefit would be either way, other than that it looks like a fixture to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I have converted _get_es to sample_es as a fixture.

Copy link
Contributor

@sarayourfriend sarayourfriend left a comment

Choose a reason for hiding this comment

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

LGTM! In looking at the ingestion server tests, I noticed this warning: https://github.com/WordPress/openverse/actions/runs/7405567531/job/20148753309?pr=3622#step:5:31

I was going to open an issue, but saw this comment on the code from @dhruvkb talking about using Bottle instead of Falcon:

https://github.com//WordPress/openverse/blob/95b59110eff953f7d30d9b9444791ae2e0dc6d68/ingestion_server/test/integration_test.py#L20-L21

Dhruv: Do you remember what the issue with Falcon was? Can you open an issue describing it? It would be nice to find a workaround to use Falcon instead or to find an alternative to Bottle, less so because of the deprecation warning and more to simplify the dependencies (which in turn means we also have fewer moving parts to worry about deprecations).

Anyway, that's a separate issue from this PR, I just wanted to bring it up for Dhruv to look at to make sure we have it recorded just in case it's an issue in the future.

…s_sensor.py

Co-authored-by: Staci Mullins <63313398+stacimc@users.noreply.github.com>
@sarayourfriend
Copy link
Contributor

@krysal @obulat are either of y'all able to review this PR this week? It'd be great to merge this.

@openverse-bot
Copy link
Collaborator

Based on the low urgency of this PR, the following reviewers are being gently reminded to review this PR:

@krysal
@obulat
This reminder is being automatically generated due to the urgency configuration.

Excluding weekend1 days, this PR was ready for review 5 day(s) ago. PRs labelled with low urgency are expected to be reviewed within 5 weekday(s)2.

@ngken0995, if this PR is not ready for a review, please draft it to prevent reviewers from getting further unnecessary pings.

Footnotes

  1. Specifically, Saturday and Sunday.

  2. For the purpose of these reminders we treat Monday - Friday as weekdays. Please note that the operation that generates these reminders runs at midnight UTC on Monday - Friday. This means that depending on your timezone, you may be pinged outside of the expected range.

Copy link
Member

@krysal krysal left a comment

Choose a reason for hiding this comment

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

Great work, @ngken0995! Thank you!

ingestion_server/test/integration_test.py Outdated Show resolved Hide resolved
Co-authored-by: Krystle Salazar <krystle.salazar@automattic.com>
@sarayourfriend sarayourfriend merged commit 03e6114 into main Jan 11, 2024
40 checks passed
@sarayourfriend sarayourfriend deleted the 3425-convert-unittest-to-pytest branch January 11, 2024 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: catalog Related to the catalog and Airflow DAGs 🧱 stack: ingestion server Related to the ingestion/data refresh server
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Convert unittest.TestCase tests to pytest
5 participants