Exemplo n.º 1
0
def test_session_initialized_when_config_provided():
    certificate = helpers.get_file_path('dummycert.crt')
    key = helpers.get_file_path('dummykey.key')
    os.environ['GITLAB_CLIENT_TOKEN'] = 'token'
    os.environ['GITLAB_CLIENT_CERTIFICATE'] = certificate
    os.environ['GITLAB_CLIENT_KEY'] = key

    gcasc = GitlabConfigurationAsCode()

    assert gcasc.gitlab.session.cert == (certificate, key)
Exemplo n.º 2
0
def test_gitlab_client_created_from_config_file(gitlab_class_mock):
    # given
    config_path = helpers.get_file_path('gitlab_config_valid.cfg')
    os.environ['GITLAB_CLIENT_CONFIG_FILE'] = config_path
    __mock_gitlab(gitlab_class_mock)

    # when
    GitlabConfigurationAsCode()

    # then
    gitlab_class_mock.from_config.assert_called_once_with("global", [config_path])
Exemplo n.º 3
0
def test_gitlab_client_created_from_config_file(gitlab_class_mock):
    # given
    config_path = helpers.get_file_path("gitlab_config_valid.cfg")
    os.environ["GITLAB_CLIENT_CONFIG_FILE"] = config_path
    __mock_gitlab(gitlab_class_mock)

    # when
    GitlabConfigurationAsCode()

    # then
    gitlab_class_mock.assert_called_once_with(
        private_token="my_token",
        url="https://my.gitlab.com",
        ssl_verify=False,
        api_version="4",
    )
Exemplo n.º 4
0
def configure_shared_environment(request):
    os.environ['GITLAB_CONFIG_FILE'] = helpers.get_file_path('gitlab.yml')

    gitlab_patch = patch('gitlab.Gitlab')
    gitlab_mock_class = gitlab_patch.__enter__()
    __mock_gitlab(gitlab_mock_class)

    def unpatch():
        gitlab_patch.__exit__()

    def clean_env():
        for key, value in os.environ.items():
            if key.startswith('GITLAB_'):
                del os.environ[key]

    request.addfinalizer(unpatch)
    request.addfinalizer(clean_env)
Exemplo n.º 5
0
def test_simple_quote_escape():
    path = get_file_path("escape_quote")
    result = read(path, quote='"')
    assert result == [('foo"oo', "bar"), ("baz", "bat")]
Exemplo n.º 6
0
def test_double_escape():
    path = get_file_path("escape_escape")
    result = read(path, quote='"')
    assert result == [('fo\\o', "bar"), ("baz", "bat")]
Exemplo n.º 7
0
def test_simple_escaped_multiline_parse():
    path = get_file_path("escape_newline")
    result = read(path)
    assert result == [("fo\no", "bar"), ("baz", "bat")]