Exemple #1
0
def test__write_zuliprc__fail_file_exists(
    minimal_zuliprc, tmpdir, id="id", key="key", url="url"
):
    path = os.path.join(str(tmpdir), "zuliprc")

    error_message = _write_zuliprc(
        path, api_key=key, server_url=url, login_id=id,
    )

    assert error_message == "zuliprc already exists at " + path
Exemple #2
0
def test__write_zuliprc__fail_file_exists(
    minimal_zuliprc: str,
    tmp_path: Path,
    id: str = "id",
    key: str = "key",
    url: str = "url",
) -> None:
    path = os.path.join(str(tmp_path), "zuliprc")

    error_message = _write_zuliprc(path, api_key=key, server_url=url, login_id=id)

    assert error_message == "zuliprc already exists at " + path
Exemple #3
0
def test__write_zuliprc__success(tmpdir, id="id", key="key", url="url"):
    path = os.path.join(str(tmpdir), "zuliprc")

    error_message = _write_zuliprc(
        path, api_key=key, server_url=url, login_id=id,
    )

    assert error_message == ""

    expected_contents = f"[api]\nemail={id}\nkey={key}\nsite={url}"
    with open(path) as f:
        assert f.read() == expected_contents

    assert stat.filemode(os.stat(path).st_mode)[-6:] == 6 * "-"