added naming to monitors, handlers and conductors so runners can identify them, in prep for in-workflow modification of patterns and recipes'

This commit is contained in:
PatchOfScotland
2023-03-16 13:53:01 +01:00
parent 9547df7612
commit f1f16ca3b8
12 changed files with 142 additions and 21 deletions

View File

@ -38,10 +38,19 @@ class MeowTests(unittest.TestCase):
super().tearDown()
teardown()
# Test LocalPythonConductor creation and job types
# Test LocalPythonConductor creation
def testLocalPythonConductorCreation(self)->None:
LocalPythonConductor()
# Test LocalPythonConductor naming
def testLocalPythonConductorNaming(self)->None:
test_name = "test_name"
conductor = LocalPythonConductor(name=test_name)
self.assertEqual(conductor.name, test_name)
conductor = LocalPythonConductor()
self.assertTrue(conductor.name.startswith("conductor_"))
# Test LocalPythonConductor executes valid python jobs
def testLocalPythonConductorValidPythonJob(self)->None:
lpc = LocalPythonConductor(

View File

@ -36,7 +36,7 @@ def recipes_equal(tester, recipe_one, recipe_two):
tester.assertEqual(recipe_one.source, recipe_two.source)
class CorrectnessTests(unittest.TestCase):
class FileEventPatternTests(unittest.TestCase):
def setUp(self)->None:
super().setUp()
setup()
@ -184,11 +184,29 @@ class CorrectnessTests(unittest.TestCase):
fep = FileEventPattern("name", "path", "recipe", "file",
sweep=bad_sweep)
class WatchdogMonitorTests(unittest.TestCase):
def setUp(self)->None:
super().setUp()
setup()
def tearDown(self)->None:
super().tearDown()
teardown()
# Test WatchdogMonitor created
def testWatchdogMonitorMinimum(self)->None:
from_monitor = Pipe()
WatchdogMonitor(TEST_MONITOR_BASE, {}, {}, from_monitor[1])
# Test WatchdogMonitor naming
def testWatchdogMonitorNaming(self)->None:
test_name = "test_name"
monitor = WatchdogMonitor(TEST_MONITOR_BASE, {}, {}, name=test_name)
self.assertEqual(monitor.name, test_name)
monitor = WatchdogMonitor(TEST_MONITOR_BASE, {}, {})
self.assertTrue(monitor.name.startswith("monitor_"))
# Test WatchdogMonitor identifies expected events in base directory
def testWatchdogMonitorEventIdentificaion(self)->None:
from_monitor_reader, from_monitor_writer = Pipe()

View File

@ -111,10 +111,28 @@ class JupyterNotebookTests(unittest.TestCase):
"name", BAREBONES_NOTEBOOK, source=source)
self.assertEqual(jnr.source, source)
class PapermillHandlerTests(unittest.TestCase):
def setUp(self)->None:
super().setUp()
setup()
def tearDown(self)->None:
super().tearDown()
teardown()
# Test PapermillHandler can be created
def testPapermillHanderMinimum(self)->None:
PapermillHandler(job_queue_dir=TEST_JOB_QUEUE)
# Test PapermillHandler naming
def testPapermillHandlerNaming(self)->None:
test_name = "test_name"
handler = PapermillHandler(name=test_name)
self.assertEqual(handler.name, test_name)
handler = PapermillHandler()
self.assertTrue(handler.name.startswith("handler_"))
# Test PapermillHandler will handle given events
def testPapermillHandlerHandling(self)->None:
from_handler_reader, from_handler_writer = Pipe()
@ -453,7 +471,6 @@ class JupyterNotebookTests(unittest.TestCase):
self.assertEqual(recipe.name, "name")
self.assertEqual(recipe.recipe, COMPLETE_NOTEBOOK)
class PythonTests(unittest.TestCase):
def setUp(self)->None:
super().setUp()
@ -513,10 +530,28 @@ class PythonTests(unittest.TestCase):
"name", BAREBONES_PYTHON_SCRIPT, requirements=requirements)
self.assertEqual(pr.requirements, requirements)
class PythonHandlerTests(unittest.TestCase):
def setUp(self)->None:
super().setUp()
setup()
def tearDown(self)->None:
super().tearDown()
teardown()
# Test PythonHandler can be created
def testPythonHandlerMinimum(self)->None:
PythonHandler(job_queue_dir=TEST_JOB_QUEUE)
# Test PythonHandler naming
def testPythonHandlerNaming(self)->None:
test_name = "test_name"
handler = PythonHandler(name=test_name)
self.assertEqual(handler.name, test_name)
handler = PythonHandler()
self.assertTrue(handler.name.startswith("handler_"))
# Test PythonHandler will handle given events
def testPythonHandlerHandling(self)->None:
from_handler_reader, from_handler_writer = Pipe()