示例#1
0
def test_set_current_context(tmp_path):
    # Re-Init config otherwise one tests collides
    config.config = configparser.ConfigParser()
    config.set_filepath(Path.joinpath(tmp_path, ".gitlabctl.ini"))
    config.set_current_context('currcontextA')
    assert config._get_current_context() == 'currcontextA'
    assert config.config['DEFAULT']['current-context'] == 'currcontextA'
示例#2
0
def test_set_context(tmp_path):
    # Re-Init config otherwise one tests collides
    config.config = configparser.ConfigParser()
    config.set_filepath(Path.joinpath(tmp_path, ".gitlabctl.ini"))
    config.set_context('testSet', 'https://lll', 'eeeee')
    assert 'testSet' in config.config.sections()
    assert config.config['testSet']['url'] == 'https://lll'
    assert config.config['testSet']['token'] == 'eeeee'
示例#3
0
def test_read_config(tmp_path, a, expected):
    config_file = write_config_example(tmp_path, a)
    # Re-Init config otherwise one tests collides
    config.config = configparser.ConfigParser()
    config.set_filepath(config_file)
    info = config.get_config()
    print("info:", info)
    assert info == expected
示例#4
0
def test_save(tmp_path):
    test_file = Path.joinpath(tmp_path, ".gitlabctl.ini")
    # Re-Init config otherwise one tests collides
    config.config = configparser.ConfigParser()
    config.set_filepath(test_file)
    config.config.read_string(CONTENT)
    config.save()
    with open(test_file) as f:
        assert f.read() == CONTENT
示例#5
0
def test_not_existing(tmp_path):
    # Re-Init config otherwise one tests collides
    config.config = configparser.ConfigParser()
    config.set_filepath(Path.joinpath(tmp_path, "NonEsiste"))
    assert not config.get_config()