示例#1
0
def domain_gh_conn_settings() -> List[cs.GhConnectionSettings]:
    """Issue fixture."""
    gh_conn_settings = [
        cs.GhConnectionSettings(
            "mytoken",
            "",
        ),
        cs.GhConnectionSettings(
            "mytoken",
            "myhost.com",
        ),
    ]
    return gh_conn_settings
def domain_gh_conn_settings() -> cs.GhConnectionSettings:
    """Issue fixture."""
    gh_conn_settings = cs.GhConnectionSettings(
        "mytoken",
        "myhost.com",
    )
    return gh_conn_settings
示例#3
0
def test_connect_github(mock_inquirer_prompt: MockerFixture) -> None:
    """It returns connection settings."""
    mock_inquirer_prompt.return_value = {
        "github_access_token": "def",
        "github_hostname": "my.host.com",
    }
    expected = gcs.GhConnectionSettings("def", "my.host.com")
    result = p.InquirerPrompter.connect_github("abc")

    assert result == expected
示例#4
0
def _get_github_service(config: c.Config) -> ghs.GithubService:
    settings = cs.GhConnectionSettings(config.github_access_token,
                                       config.github_hostname)
    try:
        return ghs.GithubService(settings)
    except AttributeError:
        response = res.ResponseFailure.build_parameters_error(
            "Wrong GitHub permissions. Please check your token.")
    except ConnectionError:
        response = res.ResponseFailure.build_system_error((
            "Unable to reach server. Please check you network and credentials and "
            "try again."))
    _echo_outputs(response)
    raise click.ClickException("")
示例#5
0
 def connect_github(github_access_token: str) -> gcs.GhConnectionSettings:
     """Prompt questions to connect to Github."""
     questions = [
         inquirer.Password(
             "github_access_token",
             message="GitHub access token",
             validate=val.not_empty_validation,
             default=github_access_token,
         ),
         inquirer.Text(
             "github_hostname",
             message="GitHub hostname (change ONLY if you use GitHub Enterprise)",
         ),
     ]
     answers = inquirer.prompt(questions)
     return gcs.GhConnectionSettings(
         answers["github_access_token"], answers["github_hostname"]
     )
def test_gh_connection_settings_model_init() -> None:
    """Verify model initialization."""
    connection_settings = cs.GhConnectionSettings("mytoken", "myhost.com")

    assert connection_settings.access_token == "mytoken"
    assert connection_settings.hostname == "myhost.com"
示例#7
0
def domain_gh_conn_settings() -> cs.GhConnectionSettings:
    """Github connection settings fixture."""
    return cs.GhConnectionSettings(
        "mytoken",
        "myhost.com",
    )