def test_reload(): init() service = Service("Test_service") service.reload() with patch.object(ansible_module_runner.AnsibleRunner, 'run') as mock_run: mock_run.return_value = ansible_run(False) ret = service.reload() assert ret[1] is False
def test_reload(): init() service = Service("Test_service") service.reload() with patch.object(ansible_module_runner.AnsibleRunner, 'run') as mock_run: mock_run.return_value = ansible_run(False) ret = service.reload() assert ret[1] is False
def test_service_reload(self, monkeypatch): def mock_AnsibleRunner_constructor(obj, asnible_module_path, **attr): assert attr == {"name": "collectd", "state": "reloaded"} return monkeypatch.setattr(AnsibleRunner, '__init__', mock_AnsibleRunner_constructor) def mock_runner_run(obj): result = { u'state': u'started', u'msg': u'', u'invocation': { u'module_args': { u'name': u'collectddd', u'enabled': None, u'daemon_reload': False, u'state': u'reloaded', u'user': False, u'masked': None } } } return result, "" monkeypatch.setattr(AnsibleRunner, 'run', mock_runner_run) service = Service("collectd") message, success = service.reload() assert message == "" assert success
def test_service_reload(self, monkeypatch): def mock_AnsibleRunner_constructor(obj, ansible_module_path, exec_path, **attr): assert attr == {"name": "collectd", "state": "reloaded"} return monkeypatch.setattr(AnsibleRunner, '__init__', mock_AnsibleRunner_constructor) def mock_runner_run(obj): result = { u'state': u'started', u'msg': u'', u'invocation': { u'module_args': { u'name': u'collectddd', u'enabled': None, u'daemon_reload': False, u'state': u'reloaded', u'user': False, u'masked': None } } } return result, "" monkeypatch.setattr(AnsibleRunner, 'run', mock_runner_run) service = Service("collectd", "/tmp/") message, success = service.reload() assert message == "" assert success