Пример #1
0
def test_linux_dirs():
    platform.system = lambda: 'Linux'

    os.environ['XDG_CONFIG_HOME'] = '/xdg_config_home'
    os.environ['XDG_CACHE_HOME'] = '/xdg_cache_home'
    os.environ['XDG_DATA_DIR'] = '/xdg_data_dir'
    os.environ['XDG_RUNTIME_DIR'] = '/xdg_runtime_dir'

    assert get_conf_path(create=False) == '/xdg_config_home'
    assert get_cache_path(create=False) == '/xdg_cache_home'
    assert get_data_path(create=False) == '/xdg_data_dir'
    assert get_runtime_path(create=False) == '/xdg_runtime_dir'
    assert get_old_runtime_path(create=False) == '/xdg_runtime_dir'
    assert get_log_path(create=False) == '/xdg_cache_home'
    assert get_autostart_path(create=False) == '/xdg_config_home/autostart'

    del os.environ['XDG_CONFIG_HOME']
    del os.environ['XDG_CACHE_HOME']
    del os.environ['XDG_DATA_DIR']
    del os.environ['XDG_RUNTIME_DIR']

    assert get_conf_path(create=False) == get_home_dir() + '/.config'
    assert get_cache_path(create=False) == get_home_dir() + '/.cache'
    assert get_data_path(create=False) == get_home_dir() + '/.local/share'
    assert get_runtime_path(create=False) == get_home_dir() + '/.cache'
    assert get_old_runtime_path(create=False) == get_home_dir() + '/.cache'
    assert get_log_path(create=False) == get_home_dir() + '/.cache'
    assert get_autostart_path(
        create=False) == get_home_dir() + '/.config/autostart'
Пример #2
0
def test_linux_dirs():
    platform.system = lambda: "Linux"

    # test that XDG environment variables for app dirs are respected

    os.environ["XDG_CONFIG_HOME"] = "/xdg_config_home"
    os.environ["XDG_CACHE_HOME"] = "/xdg_cache_home"
    os.environ["XDG_DATA_HOME"] = "/xdg_data_dir"
    os.environ["XDG_RUNTIME_DIR"] = "/xdg_runtime_dir"

    assert get_conf_path(create=False) == "/xdg_config_home"
    assert get_cache_path(create=False) == "/xdg_cache_home"
    assert get_data_path(create=False) == "/xdg_data_dir"
    assert get_runtime_path(create=False) == "/xdg_runtime_dir"
    assert get_log_path(create=False) == "/xdg_cache_home"
    assert get_autostart_path(create=False) == "/xdg_config_home/autostart"

    # test that we have reasonable fallbacks if XDG environment variables are not set

    del os.environ["XDG_CONFIG_HOME"]
    del os.environ["XDG_CACHE_HOME"]
    del os.environ["XDG_DATA_HOME"]
    del os.environ["XDG_RUNTIME_DIR"]

    assert get_conf_path(create=False) == get_home_dir() + "/.config"
    assert get_cache_path(create=False) == get_home_dir() + "/.cache"
    assert get_data_path(create=False) == get_home_dir() + "/.local/share"
    assert get_runtime_path(create=False) == get_home_dir() + "/.cache"
    assert get_log_path(create=False) == get_home_dir() + "/.cache"
    assert get_autostart_path(create=False) == get_home_dir() + "/.config/autostart"
Пример #3
0
 def _delete_old_profile_pics(self):
     # delete all old pictures
     for file in os.listdir(get_cache_path('maestral')):
         if file.startswith(self._config_name + '_profile_pic'):
             try:
                 os.unlink(osp.join(get_cache_path('maestral'), file))
             except OSError:
                 pass
Пример #4
0
 def account_profile_pic_path(self):
     """
     Returns the path of the current account's profile picture. There may not be an
     actual file at that path, if the user did not set a profile picture or the
     picture has not yet been downloaded.
     """
     return get_cache_path('maestral',
                           self._config_name + '_profile_pic.jpeg')
Пример #5
0
def test_macos_dirs():
    platform.system = lambda: "Darwin"

    assert (
        get_conf_path(create=False) == get_home_dir() + "/Library/Application Support"
    )
    assert get_cache_path(create=False) == get_conf_path(create=False)
    assert get_data_path(create=False) == get_conf_path(create=False)
    assert get_runtime_path(create=False) == get_conf_path(create=False)
    assert get_log_path(create=False) == get_home_dir() + "/Library/Logs"
    assert get_autostart_path(create=False) == get_home_dir() + "/Library/LaunchAgents"
Пример #6
0
def test_macos_dirs():
    platform.system = lambda: 'Darwin'

    assert get_conf_path(
        create=False) == get_home_dir() + '/Library/Application Support'
    assert get_cache_path(create=False) == get_conf_path(create=False)
    assert get_data_path(create=False) == get_conf_path(create=False)
    assert get_runtime_path(create=False) == get_conf_path(create=False)
    assert get_old_runtime_path(create=False) == tempfile.gettempdir()
    assert get_log_path(create=False) == get_home_dir() + '/Library/Logs'
    assert get_autostart_path(
        create=False) == get_home_dir() + '/Library/LaunchAgents'
Пример #7
0
def test_macos_dirs(monkeypatch):
    # test appdirs on macOS

    monkeypatch.setattr(platform, "system", lambda: "Darwin")

    home = get_home_dir()

    assert get_conf_path(create=False) == home + "/Library/Application Support"
    assert get_cache_path(create=False) == get_conf_path(create=False)
    assert get_data_path(create=False) == get_conf_path(create=False)
    assert get_runtime_path(create=False) == get_conf_path(create=False)
    assert get_log_path(create=False) == home + "/Library/Logs"
    assert get_autostart_path(create=False) == home + "/Library/LaunchAgents"
Пример #8
0
def test_xdg_dirs(monkeypatch):
    # test that XDG environment variables for app dirs are respected

    monkeypatch.setattr(platform, "system", lambda: "Linux")

    monkeypatch.setenv("XDG_CONFIG_HOME", "/xdg_config_home")
    monkeypatch.setenv("XDG_CACHE_HOME", "/xdg_cache_home")
    monkeypatch.setenv("XDG_DATA_HOME", "/xdg_data_dir")
    monkeypatch.setenv("XDG_RUNTIME_DIR", "/xdg_runtime_dir")

    assert get_conf_path(create=False) == "/xdg_config_home"
    assert get_cache_path(create=False) == "/xdg_cache_home"
    assert get_data_path(create=False) == "/xdg_data_dir"
    assert get_runtime_path(create=False) == "/xdg_runtime_dir"
    assert get_log_path(create=False) == "/xdg_cache_home"
    assert get_autostart_path(create=False) == "/xdg_config_home/autostart"
Пример #9
0
def test_xdg_fallback_dirs(monkeypatch):
    # test that we have reasonable fallbacks if XDG environment variables are not set

    monkeypatch.setattr(platform, "system", lambda: "Linux")

    monkeypatch.delenv("XDG_CONFIG_HOME", raising=False)
    monkeypatch.delenv("XDG_CACHE_HOME", raising=False)
    monkeypatch.delenv("XDG_DATA_HOME", raising=False)
    monkeypatch.delenv("XDG_RUNTIME_DIR", raising=False)

    home = get_home_dir()

    assert get_conf_path(create=False) == home + "/.config"
    assert get_cache_path(create=False) == home + "/.cache"
    assert get_data_path(create=False) == home + "/.local/share"
    assert get_runtime_path(create=False) == home + "/.cache"
    assert get_log_path(create=False) == home + "/.cache"
    assert get_autostart_path(create=False) == home + "/.config/autostart"