コード例 #1
0
ファイル: test_deploy.py プロジェクト: azazel75/lektor
def test_ghpages_update_git_config_https(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse("ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    branch = "lektor"
    publisher.update_git_config(str(repo_path), target_url, branch)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = https://github.com/pybee/pybee.github.io.git
        fetch = +refs/heads/lektor:refs/remotes/origin/lektor
    """).strip()
    assert repo_config.read().strip() == expected
コード例 #2
0
ファイル: test_deploy.py プロジェクト: azazel75/lektor
def test_ghpages_update_git_config(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse("ghpages://user/repo")
    branch = "master"
    publisher.update_git_config(str(repo_path), target_url, branch)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = [email protected]:user/repo.git
        fetch = +refs/heads/master:refs/remotes/origin/master
    """).strip()
    assert repo_config.read().strip() == expected
コード例 #3
0
def test_ghpages_update_git_config(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse("ghpages://user/repo")
    branch = "master"
    publisher.update_git_config(str(repo_path), target_url, branch)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = [email protected]:user/repo.git
        fetch = +refs/heads/master:refs/remotes/origin/master
    """).strip()
    assert repo_config.read().strip() == expected
コード例 #4
0
ファイル: test_deploy.py プロジェクト: isbm/lektor
def test_ghpages_update_git_config_https(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse(
        "ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    branch = "lektor"
    publisher.update_git_config(str(repo_path), target_url, branch)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = https://github.com/pybee/pybee.github.io.git
        fetch = +refs/heads/lektor:refs/remotes/origin/lektor
    """).strip()
    assert repo_config.read().strip() == expected
コード例 #5
0
def test_ghpages_update_git_config_https_credentials(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse("ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    branch = "lektor"
    credentials_file = repo_path.join('.git', 'credentials')
    credentials = {
        "username": "******",
        "password": "******",
    }
    publisher.update_git_config(str(repo_path), target_url, branch, credentials=credentials)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = https://github.com/pybee/pybee.github.io.git
        fetch = +refs/heads/lektor:refs/remotes/origin/lektor
        [credential]
        helper = store --file "{}"
    """).format(credentials_file).strip()
    assert repo_config.read().strip() == expected

    assert credentials_file.read().strip() == "https://*****:*****@github.com".strip()
コード例 #6
0
ファイル: test_deploy.py プロジェクト: sunliwen/lektor
def test_ghpages_update_git_config_https_credentials(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    repo_path = tmpdir.mkdir("repo")
    repo_config = repo_path.mkdir(".git").join("config").ensure(file=True)
    target_url = url_parse("ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    branch = "lektor"
    credentials_file = repo_path.join('.git', 'credentials')
    credentials = {
        "username": "******",
        "password": "******",
    }
    publisher.update_git_config(str(repo_path), target_url, branch, credentials=credentials)
    expected = textwrap.dedent("""
        [remote "origin"]
        url = https://github.com/pybee/pybee.github.io.git
        fetch = +refs/heads/lektor:refs/remotes/origin/lektor
        [credential]
        helper = store --file "{}"
    """).format(credentials_file).strip()
    assert repo_config.read().strip() == expected

    assert credentials_file.read().strip() == "https://*****:*****@github.com".strip()
コード例 #7
0
ファイル: test_deploy.py プロジェクト: isbm/lektor
def test_ghpages_detect_branch_username_case_insensitive(tmpdir, env):
    output_path = tmpdir.mkdir('output')
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse('ghpages+https://MacDownApp/macdownapp.github.io')
    branch = publisher.detect_target_branch(target_url)
    assert branch == 'master'
コード例 #8
0
ファイル: test_deploy.py プロジェクト: uniteddiversity/lektor
def test_ghpages_detect_branch_username(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse("ghpages+https://MacDownApp/MacDownApp.github.io")
    branch = publisher.detect_target_branch(target_url)
    assert branch == "master"
コード例 #9
0
ファイル: test_deploy.py プロジェクト: uniteddiversity/lektor
def test_ghpages_write_cname(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse("ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    publisher.write_cname(str(output_path), target_url)
    assert (output_path / "CNAME").read() == "pybee.org\n"
コード例 #10
0
def test_ghpages_detect_branch_project(tmpdir, env):
    output_path = tmpdir.mkdir('output')
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse('ghpages+https://MacDownApp/MacDownApp.github.io/macdown')
    branch = publisher.detect_target_branch(target_url)
    assert branch == 'gh-pages'
コード例 #11
0
ファイル: test_deploy.py プロジェクト: azazel75/lektor
def test_ghpages_detect_branch_project(tmpdir, env):
    output_path = tmpdir.mkdir('output')
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse('ghpages+https://MacDownApp/MacDownApp.github.io/macdown')
    branch = publisher.detect_target_branch(target_url)
    assert branch == 'gh-pages'
コード例 #12
0
ファイル: test_deploy.py プロジェクト: azazel75/lektor
def test_ghpages_detect_branch_username_case_insensitive(tmpdir, env):
    output_path = tmpdir.mkdir('output')
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse('ghpages+https://MacDownApp/macdownapp.github.io')
    branch = publisher.detect_target_branch(target_url)
    assert branch == 'master'
コード例 #13
0
ファイル: test_deploy.py プロジェクト: azazel75/lektor
def test_ghpages_write_cname(tmpdir, env):
    output_path = tmpdir.mkdir("output")
    publisher = GithubPagesPublisher(env, str(output_path))
    target_url = url_parse("ghpages+https://pybee/pybee.github.io?cname=pybee.org")
    publisher.write_cname(str(output_path), target_url)
    assert (output_path / 'CNAME').read() == "pybee.org\n"
コード例 #14
0
ファイル: test_publisher.py プロジェクト: jonathanvm13/lektor
def test_github_pages_publisher_check_error_raises(test_lines_raises):
    with pytest.raises(PublishError):
        GithubPagesPublisher._check_error(test_lines_raises)