Skip to content

Commit

Permalink
Added test to .add_job
Browse files Browse the repository at this point in the history
  • Loading branch information
HK-Mattew committed Nov 19, 2024
1 parent cc46bc0 commit 0d29f90
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,31 @@ async def test_add_job_get_result_no_ready_yet(self) -> None:
with pytest.raises(JobLookupError), fail_after(1):
await scheduler.get_job_result(job_id, wait=False)

async def test_add_job_not_rewriting_task_config(self, raw_datastore: DataStore) -> None:
async with AsyncScheduler(data_store=raw_datastore) as scheduler:
TASK_ID = 'task_dummy_async_job'
JOB_EXECUTOR = 'async'
MISFIRE_GRACE_TIME = timedelta(seconds=10)
MAX_RUNNING_JOBS = 5
METADATA = {'key': 'value'}

await scheduler.configure_task(
func_or_task_id=TASK_ID,
func=dummy_async_job,
job_executor=JOB_EXECUTOR,
misfire_grace_time=MISFIRE_GRACE_TIME,
max_running_jobs=MAX_RUNNING_JOBS,
metadata=METADATA,
)

assert await scheduler.add_job(TASK_ID)

task = await scheduler.data_store.get_task(TASK_ID)
assert task.job_executor == JOB_EXECUTOR
assert task.misfire_grace_time == MISFIRE_GRACE_TIME
assert task.max_running_jobs == MAX_RUNNING_JOBS
assert task.metadata == METADATA

async def test_contextvars(self, mocker: MockerFixture, timezone: ZoneInfo) -> None:
def check_contextvars() -> None:
assert current_async_scheduler.get() is scheduler
Expand Down

0 comments on commit 0d29f90

Please sign in to comment.