Skip to content

Commit

Permalink
Add more tests for register_task and register_process
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Sep 22, 2021
1 parent d4ae120 commit a681dc2
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test_ocs_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ def test_register_task_w_startup(mock_agent):
assert mock_agent.startup_ops == [('task', 'test_task', True)]


def test_register_task_wo_startup(mock_agent):
"""Registering a task that should not run on startup should leave the
startup_ops list empty.
"""
mock_agent.register_task('test_task', tfunc, startup=False)

print(mock_agent.startup_ops)
assert mock_agent.startup_ops == []


def test_register_task_w_startup_dict(mock_agent):
"""Registering a task that should run on startup and passing a dict to
startup, should place the task in the Agent's startup_ops list with that
dict.
"""
mock_agent.register_task('test_task', tfunc, startup={'arg1': 12})

print(mock_agent.startup_ops)
assert mock_agent.startup_ops == [('task', 'test_task', {'arg1': 12})]


def test_register_process(mock_agent):
"""Registered processes should show up in the Agent processes and sessions
dicts.
Expand All @@ -90,6 +113,29 @@ def test_register_process_w_startup(mock_agent):
assert mock_agent.startup_ops == [('process', 'test_process', True)]


def test_register_process_wo_startup(mock_agent):
"""Registering a task that should not run on startup should leave the
the Agents startup_ops list empty.
"""
mock_agent.register_process('test_process', tfunc, tfunc, startup=False)

print(mock_agent.startup_ops)
assert mock_agent.startup_ops == []


def test_register_process_w_startup_dict(mock_agent):
"""Registering a process that should run on startup and passing a dict to
startup, should place the process in the Agent's startup_ops list with that
dict.
"""
mock_agent.register_process('test_process', tfunc, tfunc, startup={'arg1': 12})

print(mock_agent.startup_ops)
assert mock_agent.startup_ops == [('process', 'test_process', {'arg1': 12})]


# Start
def test_start_task(mock_agent):
"""Test a typical task that is blocking and already not running."""
Expand Down

0 comments on commit a681dc2

Please sign in to comment.