standardised event construction and validation a bit more

This commit is contained in:
PatchOfScotland
2023-02-02 17:41:18 +01:00
parent 636d70f4e8
commit 64aaf46196
13 changed files with 243 additions and 97 deletions

View File

@ -12,7 +12,8 @@ from typing import Any, _SpecialForm, Union, Tuple, get_origin, get_args
from core.correctness.vars import VALID_PATH_CHARS, get_not_imp_msg, \
EVENT_TYPE, EVENT_PATH, JOB_EVENT, JOB_TYPE, JOB_ID, JOB_PATTERN, \
JOB_RECIPE, JOB_RULE, JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE
JOB_RECIPE, JOB_RULE, JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE, \
WATCHDOG_BASE
# Required keys in event dict
EVENT_KEYS = {
@ -23,6 +24,11 @@ EVENT_KEYS = {
EVENT_RULE: Any
}
WATCHDOG_EVENT_KEYS = {
WATCHDOG_BASE: str,
**EVENT_KEYS
}
# Required keys in job dict
JOB_KEYS = {
JOB_TYPE: str,
@ -254,3 +260,6 @@ def valid_event(event:dict[str,Any])->None:
def valid_job(job:dict[str,Any])->None:
"""Check that a given dict expresses a meow job."""
valid_meow_dict(job, "Job", JOB_KEYS)
def valid_watchdog_event(event:dict[str,Any])->None:
valid_meow_dict(event, "Watchdog event", WATCHDOG_EVENT_KEYS)