Hey Ethan,
Tests can be added to a periodic job in the same way that they are included with extensions.
Since we use pytest in the SDK, all that is really needed in a file name that starts with "test". For example, if I run "q2 create_endpoint" and create a new endpoint name "addingTests" the SDK would build a new directory (on the latest SDK version) called addingTests and an entrypoint.py is also written with some templated code. To add tests to this, I would simply create a new directory in that addingTests directory (for organizational purposes, not required) and then create a new python file in there named "test_addingTests.py". Since this file starts with "test", pytest will detect it and run the "test" methods found in the file.
Here is some example code showing what that test_addingTests.py file could look like:
import pytest
from q2_sdk.tools.testing.decorators import mock_q2_request
from .. import entrypoint
class MockTestGTFlavorHandler(entrypoint.EntryPoint):
def __init__(self):
super().__init__()
@pytest.mark.skip(reason="Generated with extension")
async def test_default_route():
handler = MockTestGTFlavorHandler()
actual = await handler.run()
mock_q2_request is used to mock any network request, or you could use pytest's monkeypatch to mock various functions with the different scenarios you are wanting to test.
Let me know if you have any questions.
Thanks,
Paden Rose
PS. We will also do some work to include tests out of the box for periodic jobs like we do with extensions.