def test_service_exists_false(self, monkeypatch):
        def mock_command_constructor(obj, command):
            assert command == "systemctl show -p LoadState " + \
                "tendrl-node-agent.service"
            return

        monkeypatch.setattr(cmd_utils.Command, '__init__',
                            mock_command_constructor)

        def mock_command_run(obj, exec_path):
            stdout = ""
            stderr = ""
            rc = 1
            return stdout, stderr, rc

        monkeypatch.setattr(cmd_utils.Command, 'run', mock_command_run)

        service = ServiceStatus("tendrl-node-agent", '/tmp/')
        exists = service.exists()
        assert not exists
Exemplo n.º 2
0
def test_exists():
    service_status = ServiceStatus("service_status")
    ret = service_status.exists()
    assert ret is False
Exemplo n.º 3
0
def get_service_info(service_name):
    service = ServiceStatus(service_name)
    return {"exists": service.exists(), "running": service.status()}