Refactor service reloading unit tests

Make sure these are consistent with the more flexible utility commands
This commit is contained in:
Matthew Jones
2017-04-10 14:00:34 -04:00
parent ea8b78ca49
commit b1c839ea62

View File

@@ -4,7 +4,7 @@ from awx.main.utils import reload
def test_produce_supervisor_command(mocker): def test_produce_supervisor_command(mocker):
with mocker.patch.object(reload.subprocess, 'Popen'): with mocker.patch.object(reload.subprocess, 'Popen'):
reload._supervisor_service_restart(['beat', 'callback', 'fact']) reload._supervisor_service_command(['beat', 'callback', 'fact'], "restart")
reload.subprocess.Popen.assert_called_once_with( reload.subprocess.Popen.assert_called_once_with(
['supervisorctl', 'restart', 'tower-processes:receiver', 'tower-processes:factcacher']) ['supervisorctl', 'restart', 'tower-processes:receiver', 'tower-processes:factcacher'])
@@ -14,13 +14,13 @@ def test_routing_of_service_restarts_works(mocker):
This tests that the parent restart method will call the appropriate This tests that the parent restart method will call the appropriate
service restart methods, depending on which services are given in args service restart methods, depending on which services are given in args
''' '''
with mocker.patch.object(reload, '_uwsgi_reload'),\ with mocker.patch.object(reload, '_uwsgi_fifo_command'),\
mocker.patch.object(reload, '_reset_celery_thread_pool'),\ mocker.patch.object(reload, '_reset_celery_thread_pool'),\
mocker.patch.object(reload, '_supervisor_service_restart'): mocker.patch.object(reload, '_supervisor_service_command'):
reload.restart_local_services(['uwsgi', 'celery', 'flower', 'daphne']) reload.restart_local_services(['uwsgi', 'celery', 'flower', 'daphne'])
reload._uwsgi_reload.assert_called_once_with() reload._uwsgi_fifo_command.assert_called_once_with(uwsgi_command="c")
reload._reset_celery_thread_pool.assert_called_once_with() reload._reset_celery_thread_pool.assert_called_once_with()
reload._supervisor_service_restart.assert_called_once_with(['flower', 'daphne']) reload._supervisor_service_command.assert_called_once_with(['flower', 'daphne'], command="restart")
@@ -28,11 +28,11 @@ def test_routing_of_service_restarts_diables(mocker):
''' '''
Test that methods are not called if not in the args Test that methods are not called if not in the args
''' '''
with mocker.patch.object(reload, '_uwsgi_reload'),\ with mocker.patch.object(reload, '_uwsgi_fifo_command'),\
mocker.patch.object(reload, '_reset_celery_thread_pool'),\ mocker.patch.object(reload, '_reset_celery_thread_pool'),\
mocker.patch.object(reload, '_supervisor_service_restart'): mocker.patch.object(reload, '_supervisor_service_command'):
reload.restart_local_services(['flower']) reload.restart_local_services(['flower'])
reload._uwsgi_reload.assert_not_called() reload._uwsgi_fifo_command.assert_not_called()
reload._reset_celery_thread_pool.assert_not_called() reload._reset_celery_thread_pool.assert_not_called()
reload._supervisor_service_restart.assert_called_once_with(['flower']) reload._supervisor_service_command.assert_called_once_with(['flower'], command="restart")