Skip to content

Commit

Permalink
Merge pull request #111 from lsst/tickets/SP-1612
Browse files Browse the repository at this point in the history
SP-1612 Add tests to ensure the Scheduler Snapshot Dashboard is working properly in LFA mode
  • Loading branch information
emanehab99 authored Oct 21, 2024
2 parents ad70d15 + 4a9e75c commit 3d5a8d9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ __version__ = "{version}"
[tool.pytest.ini_options]
addopts = "--ignore-glob=*/version.py --ignore-glob=*data_dir/*"
testpaths = "."
asyncio_default_fixture_loop_scope="function"

[tool.black]
line-length = 110
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pre-commit
boto3
botocore
playwright
pytest-asyncio
43 changes: 43 additions & 0 deletions tests/test_lfa_scheduler_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
from datetime import datetime

import pytest

# Objects to test instances against.
from rubin_scheduler.scheduler.features.conditions import Conditions
from rubin_scheduler.scheduler.schedulers.core_scheduler import CoreScheduler

from schedview.app.scheduler_dashboard.scheduler_dashboard_app import LFASchedulerSnapshotDashboard


@pytest.mark.asyncio
async def test_get_scheduler_list():
scheduler = LFASchedulerSnapshotDashboard()
scheduler.telescope = None
await scheduler.get_scheduler_list()
# No snapshots should be retreived if it isn't an LFA environment
# the dropdown has one empty option
assert len(scheduler.param.scheduler_fname.objects) >= 1


@pytest.mark.asyncio
async def test_get_scheduler_list_in_USDF():
scheduler = LFASchedulerSnapshotDashboard()

scheduler.telescope = None
scheduler.pickles_date = datetime(2024, 10, 1, 21, 26, 23)
await scheduler.get_scheduler_list()
# make sure it's a LFA environment by checking
# the env variables needed for LFA mode are set
if os.environ.get("AWS_SHARED_CREDENTIALS_FILE") and os.environ.get("S3_ENDPOINT_URL"):
# at least one snapshot file should be retreived
# the dropdown should have one empty option +
# at least one snapshot
assert len(scheduler.param.scheduler_fname.objects) >= 2
scheduler.scheduler_fname = scheduler.param["scheduler_fname"].objects[1]
scheduler.read_scheduler()
assert isinstance(scheduler._scheduler, CoreScheduler)
assert isinstance(scheduler._conditions, Conditions)
else:
# pass the test if it isn't an LFA environment
pass

0 comments on commit 3d5a8d9

Please sign in to comment.