Skip to content

Commit

Permalink
Test all Django Job Scheduling Jobs are monitored
Browse files Browse the repository at this point in the history
Check that all jobs in jobserver.jobs have their `execute` methods
annotated correctly (e.g. `@monitor` but not `@monitor()`)
  • Loading branch information
Jongmassey committed Jul 17, 2024
1 parent 131e5a7 commit bade1fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Empty file.
20 changes: 20 additions & 0 deletions tests/unit/jobserver/jobs/test_jobs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pkgutil

import jobserver.jobs


def test_jobs_annotated():
for moduleinfo in pkgutil.walk_packages(jobserver.jobs.__path__, "jobserver.jobs."):
if len(moduleinfo.name.split(".")) <= 3:
continue

module = pkgutil.resolve_name(moduleinfo.name)
job = module.Job
execute = job.execute

# check the monitor decorator is imported
assert "monitor" in module.__dict__
# check the execute function has been decorated by something using functools.wraps
assert "__wrapped__" in execute.__dict__
# check the thing that decorated it came from services.sentry
assert execute.__globals__["__name__"] == "services.sentry"

0 comments on commit bade1fd

Please sign in to comment.