Exemplo n.º 1
0
def test_get_config_raises(tmpdir, caplog):
    tmp_config = tmpdir.mkdir("klio-exec-testing")

    does_not_exist = os.path.join(str(tmp_config), "klio-config.yaml")
    with pytest.raises(SystemExit):
        cli._get_config(does_not_exist)

    assert 1 == len(caplog.records)
Exemplo n.º 2
0
def test_get_config_loaded_safely(tmpdir, config, mocker, monkeypatch):
    mock_safe_load = mocker.Mock()
    mock_safe_load.return_value = config
    monkeypatch.setattr(cli.yaml, "safe_load", mock_safe_load)
    tmp_config = tmpdir.mkdir("klio-exec-testing").join("klio-job.yaml")

    open_name = "klio_exec.cli.open"
    config_str = yaml.dump(config)
    m_open = mocker.mock_open(read_data=config_str)
    m = mocker.patch(open_name, m_open)

    cli._get_config(tmp_config.strpath)
    m.assert_called_once_with(tmp_config.strpath)
    mock_safe_load.assert_called_once_with(m_open.return_value)
Exemplo n.º 3
0
def test_get_config(tmpdir, config):
    tmp_config = tmpdir.mkdir("klio-exec-testing").join("klio-job.yaml")
    tmp_config.write(yaml.dump(config))

    ret_config = cli._get_config(str(tmp_config))
    assert config == ret_config