-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ validate-pyproject<0.16 | |
|
||
# Software tests | ||
httpx<0.26 | ||
psycopg2-binary<3 | ||
pytest<8 | ||
pytest-cov<5 | ||
pytest-mock<4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
from main import main | ||
import pytest | ||
import sqlalchemy as sa | ||
|
||
from main import run_supertask | ||
|
||
def test_main(mocker, caplog): | ||
mocker.patch("main.Supertask.wait") | ||
|
||
def check_store(address: str): | ||
engine: sa.engine.Engine = sa.create_engine(url=address) | ||
try: | ||
with engine.connect() as conn: | ||
conn.execute(sa.text("SELECT 1;")) | ||
except sa.exc.OperationalError as ex: | ||
if "No more Servers available" in str(ex): | ||
raise pytest.skip(f"Skipping test case, because job store is not available: {address}") from ex | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"job_store_address", ["memory://", "postgresql://postgres:postgres@localhost", "crate://crate@localhost"] | ||
) | ||
def test_run_supertask(mocker, caplog, job_store_address): | ||
if not job_store_address.startswith("memory://"): | ||
check_store(job_store_address) | ||
mocker.patch("main.Supertask.start_http_service") | ||
main() | ||
run_supertask(job_store_address, pre_delete_jobs=True) | ||
assert "Configuring scheduler" in caplog.messages | ||
assert "Seeding jobs" in caplog.messages | ||
assert "Adding job tentatively -- it will be properly scheduled when the scheduler starts" in caplog.messages | ||
assert "Starting scheduler" in caplog.messages | ||
assert 'Added job "my_job" to job store "default"' in caplog.messages | ||
|
||
|
||
def test_run_supertask_unknown(): | ||
with pytest.raises(RuntimeError) as ex: | ||
run_supertask("foo://") | ||
assert ex.match("Initializing job store failed. Unknown address: foo://") |