diff --git a/tests/unit/jobserver/jobs/__init__.py b/tests/unit/jobserver/jobs/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/jobserver/jobs/test_jobs.py b/tests/unit/jobserver/jobs/test_jobs.py new file mode 100644 index 0000000000..b7554229bb --- /dev/null +++ b/tests/unit/jobserver/jobs/test_jobs.py @@ -0,0 +1,20 @@ +import pkgutil + +import jobserver.jobs + + +def test_jobs_monitored(): + 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"