def test_get_dir(): assert get_dir("config", disable_debug=True) == Path(user_config_dir(), APP_NAME) assert get_dir("cache", disable_debug=True) == Path(user_cache_dir(), APP_NAME) assert get_dir("data", disable_debug=True) == Path(user_data_dir(), APP_NAME) with TemporaryDirectory() as n: with patch("mydevoirs.utils.appdirs.user_cache_dir", return_value=n): assert not Path(n, APP_NAME).exists() get_dir("cache", disable_debug=True) assert Path(n, APP_NAME).is_dir()
def get_application_config(self, disable_debug=None): return super().get_application_config( str( Path(get_dir("config", disable_debug=disable_debug), "settings.ini").absolute()))
"title": "chemin de la base de donné", "desc": "", "section": "ddb", "key": "path", }, ] DEFAULT_SETTINGS = { "agenda": { "lundi": 1, "mardi": 1, "mercredi": 0, "jeudi": 1, "vendredi": 1, "samedi": 0, "dimanche": 0, "start_day": "lundi", "auto_next_week": 1, }, "ddb": { "path": str(get_dir("cache") / DDB_FILENAME), "file_config_path": "" }, "aide": { "aide": homepage, "version": VERSION }, } SETTING_PANELS = [("Agenda", json.dumps(AGENDA_PANEL))]
def test_get_dir_env(monkeypatch): monkeypatch.setenv("MYDEVOIRS_DEBUG", "True") assert (get_dir("config", enable_pytest=False) == Path(tempfile.gettempdir()) / "mydevoirs_debug" / "config" / APP_NAME)
def test_ddb_path(): assert Path(DEFAULT_SETTINGS["ddb"]["path"]) == Path( get_dir("cache", enable_pytest=False), DDB_FILENAME ) assert str(DDB)[-26:] == str(Path(DEFAULT_SETTINGS["ddb"]["path"]))[-26:]