Ejemplo n.º 1
0
def test_github_access_token_errors_if_provided_and_not_found(monkeypatch):
    mock_github = MagicMock(wraps=github.Github)
    monkeypatch.setattr("github.Github", mock_github)
    storage = GitHub(repo="test/repo",
                     path="flow.py",
                     access_token_secret="MISSING")
    with context(secrets={}):
        with pytest.raises(Exception, match="MISSING"):
            storage._get_github_client()
Ejemplo n.º 2
0
def test_github_access_token_secret(monkeypatch, secret_name, secret_arg):
    orig_github = github.Github
    mock_github = MagicMock(wraps=github.Github)
    monkeypatch.setattr("github.Github", mock_github)
    storage = GitHub(repo="test/repo",
                     path="flow.py",
                     access_token_secret=secret_arg)
    with context(secrets={secret_name: "TEST-VAL"}):
        client = storage._get_github_client()
    assert isinstance(client, orig_github)
    assert mock_github.call_args[0][0] == "TEST-VAL"
Ejemplo n.º 3
0
def test_github_base_url(monkeypatch):
    orig_github = github.Github
    mock_github = MagicMock(wraps=github.Github)
    monkeypatch.setattr("github.Github", mock_github)
    storage = GitHub(
        repo="test/repo",
        path="flow.py",
        access_token_secret="TEST",
        base_url="https://some-url",
    )
    with context(secrets={"TEST": "TEST-VAL"}):
        client = storage._get_github_client()
    assert isinstance(client, orig_github)
    assert mock_github.call_args[1]["base_url"] == "https://some-url"