-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test all Django Job Scheduling Jobs are monitored
Check that all jobs in jobserver.jobs have their `execute` methods annotated correctly (e.g. `@monitor` but not `@monitor()`)
- Loading branch information
1 parent
131e5a7
commit bade1fd
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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 |
---|---|---|
@@ -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" |