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'
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'
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
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
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()