standardised event construction and validation a bit more
This commit is contained in:
@ -9,10 +9,11 @@ from typing import Any, Union
|
||||
from core.correctness.validation import check_type, check_implementation, \
|
||||
valid_string, valid_dict, valid_list, valid_existing_file_path, \
|
||||
valid_existing_dir_path, valid_non_existing_path, valid_event, valid_job, \
|
||||
setup_debugging
|
||||
setup_debugging, valid_watchdog_event
|
||||
from core.correctness.vars import VALID_NAME_CHARS, SHA256, EVENT_TYPE, \
|
||||
EVENT_PATH, JOB_TYPE, JOB_EVENT, JOB_ID, JOB_PATTERN, JOB_RECIPE, \
|
||||
JOB_RULE, JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE
|
||||
JOB_RULE, JOB_STATUS, JOB_CREATE_TIME, EVENT_RULE, WATCHDOG_BASE, \
|
||||
WATCHDOG_HASH
|
||||
from core.functionality import make_dir
|
||||
from shared import setup, teardown, TEST_MONITOR_BASE
|
||||
|
||||
@ -303,4 +304,36 @@ class CorrectnessTests(unittest.TestCase):
|
||||
with self.assertRaises(TypeError):
|
||||
setup_debugging(stream, "1")
|
||||
|
||||
#TODO test watchdog event dict
|
||||
#Test watchdog event dict
|
||||
def testWatchdogEventValidation(self)->None:
|
||||
valid_watchdog_event({
|
||||
EVENT_TYPE: "test",
|
||||
EVENT_PATH: "path",
|
||||
EVENT_RULE: "rule",
|
||||
WATCHDOG_HASH: "hash",
|
||||
WATCHDOG_BASE: "base"
|
||||
})
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
valid_watchdog_event({
|
||||
EVENT_TYPE: "test",
|
||||
EVENT_PATH: "path",
|
||||
EVENT_RULE: "rule"
|
||||
})
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
valid_watchdog_event({
|
||||
EVENT_TYPE: "anything",
|
||||
EVENT_PATH: "path",
|
||||
EVENT_RULE: "rule",
|
||||
"a": 1
|
||||
})
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
valid_event({EVENT_TYPE: "test"})
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
valid_event({"EVENT_TYPE": "test"})
|
||||
|
||||
with self.assertRaises(KeyError):
|
||||
valid_event({})
|
Reference in New Issue
Block a user