Skip to content

Commit

Permalink
swap appdirs for platformdirs
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair committed Jan 23, 2024
1 parent 8545c6d commit 4019dd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dkist/net/globus/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import parse_qs, urlparse

import appdirs
import globus_sdk
import platformdirs

CLIENT_ID = 'dd2d62af-0b44-4e2e-9454-1092c94b46b3'
SCOPES = ('urn:globus:auth:scope:transfer.api.globus.org:all',
Expand Down Expand Up @@ -80,7 +80,7 @@ def get_cache_file_path():
"""
Use appdirs to get the cache path for the user and add the filename.
"""
cache_dir = Path(appdirs.user_cache_dir("dkist"))
cache_dir = Path(platformdirs.user_cache_dir("dkist"))
return cache_dir / "globus_auth_cache.json"


Expand Down
10 changes: 5 additions & 5 deletions dkist/net/globus/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_http_server():


def test_get_cache_file_path(mocker):
mocker.patch("appdirs.user_cache_dir", return_value="/tmp/test/")
mocker.patch("platformdirs.user_cache_dir", return_value="/tmp/test/")
path = get_cache_file_path()
assert isinstance(path, pathlib.Path)

Expand All @@ -33,15 +33,15 @@ def test_get_cache_file_path(mocker):


def test_get_no_cache(mocker, tmpdir):
mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir))
mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir))
# Test file not exists
cache = get_cache_contents()
assert isinstance(cache, dict)
assert not cache


def test_get_cache(mocker, tmpdir):
mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir))
mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir))
with open(tmpdir / "globus_auth_cache.json", "w") as fd:
json.dump({"hello": "world"}, fd)

Expand All @@ -52,7 +52,7 @@ def test_get_cache(mocker, tmpdir):


def test_get_cache_not_json(mocker, tmpdir):
mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir))
mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir))
with open(tmpdir / "globus_auth_cache.json", "w") as fd:
fd.write("aslkjdasdjjdlsajdjklasjdj, akldjaskldjasd, lkjasdkljasldkjas")

Expand All @@ -64,7 +64,7 @@ def test_get_cache_not_json(mocker, tmpdir):
def test_save_auth_cache(mocker, tmpdir):
filename = tmpdir / "globus_auth_cache.json"
assert not filename.exists() # Sanity check
mocker.patch("appdirs.user_cache_dir", return_value=str(tmpdir))
mocker.patch("platformdirs.user_cache_dir", return_value=str(tmpdir))
save_auth_cache({"hello": "world"})

assert filename.exists()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ packages = find:
include_package_data = True
install_requires =
aiohttp>=3.6
appdirs>=1.4
platformdirs>=3.0
asdf>=2.11.2 # Pick up jsonschema bug fix
asdf-astropy>=0.2.0
asdf-transform-schemas>=0.3.0
Expand Down

0 comments on commit 4019dd3

Please sign in to comment.