Skip to content

Conversation

@michaelwaves
Copy link
Contributor

A start to integrating pytest

-add pytest and dependencies to requirements.in
-add instructions to readme
-add conftest.py
-add test_ping in test_app.py

JadenFiotto-Kaufman and others added 15 commits October 24, 2025 15:53
tagging the ray image in ga workflow
bug fix with non serializable result
Connect to object store in coordinator
test_app.py tests ping api route
note: fastapi TestClient(app) doesn't work due to fastapi mounting socketio
you must cd to the src/services/api directory before running pytest (added this to readme)
this is currently in a draft state and should not be merged
Alert users and purge requests for processors that fail to deploy (in…
@MichaelRipa MichaelRipa changed the base branch from main to dev November 10, 2025 19:59
@MichaelRipa
Copy link
Member

Thanks for your contributions! I'm going to review this in more detail later this week, but wanted to give a few initial comments:

  • It's not documented anywhere yet, but typically we make PR's into dev branch first (I changed this for you)
  • I'd like to have these tests organized under a unit subdirectory, and have a way to be able to specify only running unit tests. It's somewhat trivial, but at some point, we'll have integrated / end-to-end tests so it would have having things already organized 🙂

@michaelwaves michaelwaves marked this pull request as ready for review November 17, 2025 02:47
README.md Outdated

For more comprehensive testing, install pytest
```sh
conda activate ndif-dev
Copy link
Member

Choose a reason for hiding this comment

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

Instead of assuming a package manager and instructing them how to install it, just directly link to pytest docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point

@@ -0,0 +1,28 @@
import time
from functools import lru_cache
from src.queue.util import cache_maintainer
Copy link
Member

Choose a reason for hiding this comment

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

This helper function is getting removed in #210

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm it seems like there are a lot of changes happening to queue/util.py, maybe we should just delete test_queue_util.py for now?


## Testing

install dependencies from requirements.in, ideally in a virtual environment
Copy link
Member

Choose a reason for hiding this comment

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

There's also the dependencies in the pyproject.toml

@@ -0,0 +1,10 @@
from unittest.mock import MagicMock, patch
Copy link
Member

Choose a reason for hiding this comment

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

The repo structure is a little confusing, but this technically corresponds to src/common, so this test isn't needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see. I removed the file for now since there are no other functions to test in providers/util.py. Are there any api specific utils we should test or is this fine for now?

[project]
name = "api"
version = "0.1.0"
requires-python = ">=3.10"
Copy link
Member

Choose a reason for hiding this comment

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

Technically right now we only run NDIF with python 3.12

pythonpath = ["."]

[dependency-groups]
dev = [
Copy link
Member

Choose a reason for hiding this comment

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

I think "tests" would be a more appropriate dependency group name

@@ -0,0 +1,13 @@
import os
os.environ["DEV_MODE"] = "true"
Copy link
Member

Choose a reason for hiding this comment

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

You set this here, but also directly in some of the tests, was this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the two tests were specifically testing the behavior in dev mode so I wanted it to be explicit. The top level DEV_MODE is just to avoid start the db connection in db.py. In e2e testing we might want to set this to be false with a separate conftest.py

Copy link
Member

@MichaelRipa MichaelRipa left a comment

Choose a reason for hiding this comment

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

Great progress! I cloned and tested this out locally, and it seemed to work once I installed all the dependencies. I added some comments for review, once they are addressed, it'll be close to ready for merge 🙂

@MichaelRipa
Copy link
Member

Looks good to me. Will just get a second pair of eyes from @JadenFiotto-Kaufman

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.

3 participants