added interaction for monitor state updating
This commit is contained in:
@ -4,7 +4,7 @@ import os
|
||||
import unittest
|
||||
|
||||
from multiprocessing import Pipe
|
||||
from typing import Any
|
||||
from typing import Any, Union
|
||||
|
||||
from core.correctness.vars import TEST_HANDLER_BASE, TEST_JOB_OUTPUT, \
|
||||
TEST_MONITOR_BASE, BAREBONES_NOTEBOOK, WATCHDOG_BASE, WATCHDOG_RULE, \
|
||||
@ -131,24 +131,42 @@ class MeowTests(unittest.TestCase):
|
||||
|
||||
def testBaseMonitor(self)->None:
|
||||
with self.assertRaises(TypeError):
|
||||
BaseMonitor("")
|
||||
BaseMonitor({}, {})
|
||||
|
||||
class TestMonitor(BaseMonitor):
|
||||
pass
|
||||
|
||||
with self.assertRaises(NotImplementedError):
|
||||
TestMonitor("")
|
||||
TestMonitor({}, {})
|
||||
|
||||
class FullTestMonitor(BaseMonitor):
|
||||
def start(self):
|
||||
pass
|
||||
def stop(self):
|
||||
pass
|
||||
def _is_valid_to_runner(self, to_runner:Any)->None:
|
||||
def _is_valid_patterns(self, patterns:dict[str,BasePattern])->None:
|
||||
pass
|
||||
def _is_valid_rules(self, rules:Any)->None:
|
||||
def _is_valid_recipes(self, recipes:dict[str,BaseRecipe])->None:
|
||||
pass
|
||||
FullTestMonitor("")
|
||||
def add_pattern(self, pattern:BasePattern)->None:
|
||||
pass
|
||||
def update_pattern(self, pattern:BasePattern)->None:
|
||||
pass
|
||||
def remove_pattern(self, pattern:Union[str,BasePattern])->None:
|
||||
pass
|
||||
def get_patterns(self)->None:
|
||||
pass
|
||||
def add_recipe(self, recipe:BaseRecipe)->None:
|
||||
pass
|
||||
def update_recipe(self, recipe:BaseRecipe)->None:
|
||||
pass
|
||||
def remove_recipe(self, recipe:Union[str,BaseRecipe])->None:
|
||||
pass
|
||||
def get_recipes(self)->None:
|
||||
pass
|
||||
def get_rules(self)->None:
|
||||
pass
|
||||
FullTestMonitor({}, {})
|
||||
|
||||
def testMonitoring(self)->None:
|
||||
pattern_one = FileEventPattern(
|
||||
@ -163,20 +181,21 @@ class MeowTests(unittest.TestCase):
|
||||
recipes = {
|
||||
recipe.name: recipe,
|
||||
}
|
||||
rules = create_rules(patterns, recipes)
|
||||
|
||||
rule = rules[list(rules.keys())[0]]
|
||||
|
||||
monitor_debug_stream = io.StringIO("")
|
||||
|
||||
wm = WatchdogMonitor(
|
||||
TEST_MONITOR_BASE,
|
||||
rules,
|
||||
patterns,
|
||||
recipes,
|
||||
print=monitor_debug_stream,
|
||||
logging=3,
|
||||
settletime=1
|
||||
)
|
||||
|
||||
rules = wm.get_rules()
|
||||
rule = rules[list(rules.keys())[0]]
|
||||
|
||||
from_monitor_reader, from_monitor_writer = Pipe()
|
||||
wm.to_runner = from_monitor_writer
|
||||
|
||||
@ -225,9 +244,6 @@ class MeowTests(unittest.TestCase):
|
||||
recipes = {
|
||||
recipe.name: recipe,
|
||||
}
|
||||
rules = create_rules(patterns, recipes)
|
||||
|
||||
rule = rules[list(rules.keys())[0]]
|
||||
|
||||
start_dir = os.path.join(TEST_MONITOR_BASE, "start")
|
||||
make_dir(start_dir)
|
||||
@ -241,12 +257,16 @@ class MeowTests(unittest.TestCase):
|
||||
|
||||
wm = WatchdogMonitor(
|
||||
TEST_MONITOR_BASE,
|
||||
rules,
|
||||
patterns,
|
||||
recipes,
|
||||
print=monitor_debug_stream,
|
||||
logging=3,
|
||||
settletime=1
|
||||
)
|
||||
|
||||
rules = wm.get_rules()
|
||||
rule = rules[list(rules.keys())[0]]
|
||||
|
||||
from_monitor_reader, from_monitor_writer = Pipe()
|
||||
wm.to_runner = from_monitor_writer
|
||||
|
||||
|
@ -147,7 +147,7 @@ class CorrectnessTests(unittest.TestCase):
|
||||
|
||||
def testWatchdogMonitorMinimum(self)->None:
|
||||
from_monitor = Pipe()
|
||||
WatchdogMonitor(TEST_MONITOR_BASE, {}, from_monitor[1])
|
||||
WatchdogMonitor(TEST_MONITOR_BASE, {}, {}, from_monitor[1])
|
||||
|
||||
def testWatchdogMonitorEventIdentificaion(self)->None:
|
||||
from_monitor_reader, from_monitor_writer = Pipe()
|
||||
@ -163,11 +163,12 @@ class CorrectnessTests(unittest.TestCase):
|
||||
recipes = {
|
||||
recipe.name: recipe,
|
||||
}
|
||||
rules = create_rules(patterns, recipes)
|
||||
|
||||
wm = WatchdogMonitor(TEST_MONITOR_BASE, rules)
|
||||
wm = WatchdogMonitor(TEST_MONITOR_BASE, patterns, recipes)
|
||||
wm.to_runner = from_monitor_writer
|
||||
|
||||
|
||||
rules = wm.get_rules()
|
||||
|
||||
self.assertEqual(len(rules), 1)
|
||||
rule = rules[list(rules.keys())[0]]
|
||||
|
||||
|
@ -44,7 +44,6 @@ class MeowTests(unittest.TestCase):
|
||||
recipes = {
|
||||
recipe.name: recipe,
|
||||
}
|
||||
rules = create_rules(patterns, recipes)
|
||||
|
||||
monitor_debug_stream = io.StringIO("")
|
||||
handler_debug_stream = io.StringIO("")
|
||||
@ -52,7 +51,8 @@ class MeowTests(unittest.TestCase):
|
||||
runner = MeowRunner(
|
||||
WatchdogMonitor(
|
||||
TEST_MONITOR_BASE,
|
||||
rules,
|
||||
patterns,
|
||||
recipes,
|
||||
print=monitor_debug_stream,
|
||||
logging=3,
|
||||
settletime=1
|
||||
@ -142,7 +142,8 @@ class MeowTests(unittest.TestCase):
|
||||
runner = MeowRunner(
|
||||
WatchdogMonitor(
|
||||
TEST_MONITOR_BASE,
|
||||
rules,
|
||||
patterns,
|
||||
recipes,
|
||||
print=monitor_debug_stream,
|
||||
logging=3,
|
||||
settletime=1
|
||||
|
Reference in New Issue
Block a user