def test_load_not_file(fx_tmpdir: pathlib.Path): """Test config load function - not exists file""" path = fx_tmpdir / 'path' path.mkdir() with pytest.raises(SystemExit): load(path)
def test_load_not_correct_suffix(fx_tmpdir: pathlib.Path): """Test config load function - not correct suffix""" file = fx_tmpdir / 'conf.py' file.touch() with pytest.raises(SystemExit): load(file)
def test_load_empty(fx_tmpdir: pathlib.Path): """Test config load function - empty file""" file = fx_tmpdir / 'empty.config.toml' file.touch() with pytest.raises(SystemExit): load(file)
def test_load_fine(fx_tmpdir: pathlib.Path): """Test config load function - empty file""" file = fx_tmpdir / 'yui.config.toml' with file.open('w') as f: f.write(''' TOKEN = 'asdf' DEBUG = true PREFIX = '.' APPS = ['a', 'b'] [CHANNELS] general = '_general' [USERS] owner = 'U111' ''') config = load(file) assert config.TOKEN == 'asdf' assert config.DEBUG assert config.PREFIX == '.' assert config.APPS == ['a', 'b'] assert config.CHANNELS == { 'general': '_general', }
def test_load_fine(fx_tmpdir: pathlib.Path): """Test config load function - empty file""" file = fx_tmpdir / "yui.config.toml" with file.open("w") as f: f.write(""" TOKEN = 'asdf' DATABASE_URL = 'sqlite:///:memory:' DEBUG = true PREFIX = '.' APPS = ['a', 'b'] [CHANNELS] general = '_general' [USERS] owner = 'U111' """) config = load(file) assert config.TOKEN == "asdf" assert config.DEBUG assert config.PREFIX == "." assert config.APPS == ["a", "b"] assert config.CHANNELS == { "general": "_general", }
def test_load_empty(fx_tmpdir: pathlib.Path): """Test config load function - empty file""" file = fx_tmpdir / 'empty.config.toml' file.touch() config = load(file) assert not config.DEBUG assert config.PREFIX == '' assert config.APPS == []
def test_load_fine(fx_tmpdir: pathlib.Path): """Test config load function - empty file""" file = fx_tmpdir / 'yui.config.toml' with file.open('w') as f: f.write(''' DEBUG = true PREFIX = '.' APPS = ['a', 'b'] ''') config = load(file) assert config.DEBUG assert config.PREFIX == '.' assert config.APPS == ['a', 'b']