Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap appdirs for platformdirs #318

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/318.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change the ``appdirs`` dependancy for the maintained ``platformdirs`` package.
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

Check warning on line 18 in dkist/net/globus/auth.py

View check run for this annotation

Codecov / codecov/patch

dkist/net/globus/auth.py#L18

Added line #L18 was not covered by tests

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 @@
"""
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"))

Check warning on line 83 in dkist/net/globus/auth.py

View check run for this annotation

Codecov / codecov/patch

dkist/net/globus/auth.py#L83

Added line #L83 was not covered by tests
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
Loading