def test_service_restart(self, monkeypatch): def mock_AnsibleRunner_constructor(obj, ansible_module_path, exec_path, **attr): assert attr == {"name": "collectd", "state": "restarted"} 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'restarted', u'user': False, u'masked': None } } } return result, "" monkeypatch.setattr(AnsibleRunner, 'run', mock_runner_run) service = Service("collectd", "/tmp") message, success = service.restart() assert message == "" assert success
def test_service_restart(self, monkeypatch): def mock_AnsibleRunner_constructor(obj, asnible_module_path, **attr): assert attr == {"name": "collectd", "state": "restarted"} 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'restarted', u'user': False, u'masked': None } } } return result, "" monkeypatch.setattr(AnsibleRunner, 'run', mock_runner_run) service = Service("collectd") message, success = service.restart() assert message == "" assert success
def test_restart(): init() service = Service("Test_service") with patch.object(ansible_module_runner, 'AnsibleRunner', ansible) as mock_ansible: with pytest.raises(ansible_module_runner.AnsibleModuleNotFound): ret = service.restart()
def test_restart(): init() service = Service("Test_service") with patch.object(ansible_module_runner, 'AnsibleRunner', ansible): with pytest.raises(ansible_module_runner.AnsibleModuleNotFound): service.restart()