def test_empty_or_invalid_gen_users_settings(tmp_path, action, setting): # 'not an int' will be ignored for delete if type(setting) == str: actions = (action('lscat', setting, 'not an int'), ) else: actions = (action('lscat', setting[0], 'not an int'), action('lscat', setting[1], 'not an int')) testconfig = setup_test_config(tmp_path, config.Config, *actions) assert testconfig.gen_users_settings() == (18, 2)
def test_empty_or_invalid_image_setting(tmp_path, action, side, dimension, fallback): testconfig = setup_test_config( tmp_path, config.Config, action('lscat', f'image_{side}', 'not an int'), action('lscat', f'images_{dimension}_spacing', 'not an int')) assert testconfig.dimension(eval(f'config.Dimension.{dimension}'), fallback) == fallback assert testconfig.dimension(eval(f'config.Dimension.{dimension}'), (1, 1)) == (1, 1)
def test_set_dimension(tmp_path, side, dimension, _): testconfig = setup_test_config( tmp_path, config.Config, Processer.set('lscat', f'image_{side}', 15), Processer.set('lscat', f'images_{dimension}_spacing', 3)) assert testconfig.dimension(eval(f'config.Dimension.{dimension}'), (1, 1)) == (15, 3)
def test_dimension_default(tmp_path): testconfig = setup_test_config(tmp_path, config.Config) assert testconfig.dimension(config.Dimension.x, (1, 1)) == (18, 2) assert testconfig.dimension(config.Dimension.y, (1, 1)) == (8, 1)
def test_users_page_spacing_default(tmp_path): testconfig = setup_test_config(tmp_path, config.Config) assert testconfig.users_page_spacing() == 20
def test_set_ints(tmp_path, setting, section, method): testconfig = setup_test_config(tmp_path, config.Config, Processer.set(section, method, setting)) assert eval(f'testconfig.{method}()') == setting
def test_set_boolean_to_false(tmp_path, setting, section, method): testconfig = setup_test_config(tmp_path, config.Config, Processer.set(section, method, setting)) assert eval(f'testconfig.{method}()') is False
def test_empty_or_invalid_setting(tmp_path, action, section, method, fallback): testconfig = setup_test_config( tmp_path, config.Config, action(section, method, 'not a boolean; not an int or list either')) assert eval(f'testconfig.{method}()') == fallback
def test_method_defaults(tmp_path, _, method, expected): testconfig = setup_test_config(tmp_path, config.Config) assert eval(f'testconfig.{method}()') == expected
def test_begin_config_exists(monkeypatch, tmp_path, use_test_cfg_path): testconfig = setup_test_config(tmp_path, config.Config) monkeypatch.setattr('koneko.config.api', testconfig) creds = config.begin_config() assert creds['refresh_token'] == 'token'
def test_gallery_print_spacing_empty_or_invalid(tmp_path, action): testconfig = setup_test_config( tmp_path, config.Config, action('lscat', 'gallery_print_spacing', 'not an int')) assert testconfig.gallery_print_spacing() == [9, 17, 17, 17, 17]
def test_set_gallery_print_spacing(tmp_path, setting): testconfig = setup_test_config( tmp_path, config.Config, Processer.set('lscat', 'gallery_print_spacing', ','.join([str(x) for x in list(setting)]))) assert testconfig.gallery_print_spacing() == list(setting)
def test_gallery_print_spacing_default(tmp_path): testconfig = setup_test_config(tmp_path, config.Config) assert testconfig.gallery_print_spacing() == [9, 17, 17, 17, 17]
def test_set_gen_users_settings(tmp_path): testconfig = setup_test_config( tmp_path, config.Config, Processer.set('lscat', 'users_print_name_xcoord', 10), Processer.set('lscat', 'images_x_spacing', 3)) assert testconfig.gen_users_settings() == (10, 3)
def test_gen_users_settings_default(tmp_path): testconfig = setup_test_config(tmp_path, config.Config) assert testconfig.gen_users_settings() == (18, 2)