Skip to content

Commit

Permalink
update configuration unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Raney committed Nov 19, 2021
1 parent 681fd0c commit 0ccff67
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
import pickle
from hydroshare_jupyter_sync.config_setup import ConfigFile, FileNotDirectoryError
from hydroshare_on_jupyter.config_setup import ConfigFile, FileNotDirectoryError
from tempfile import TemporaryDirectory, TemporaryFile
from pathlib import Path

Expand Down Expand Up @@ -34,6 +34,7 @@ def test_config_using_env_vars(monkeypatch):
def test_config_using_env_file():
"""Test configuration using environment variables"""
with TemporaryDirectory() as temp:
temp = Path(temp).resolve()
log = Path(temp) / "logs"
env_contents = f"""
DATA={temp}
Expand Down Expand Up @@ -67,12 +68,12 @@ def oauth_file(oauth_data) -> Path:

filename = ".hs_auth"
with TemporaryDirectory() as dir:
oauth_path = Path(dir) / filename
oauth_path = (Path(dir) / filename).resolve()
with open(oauth_path, "wb") as f:
pickle.dump(oauth_data, f, protocol=2)
yield oauth_path


def test_config_oauth(oauth_file, oauth_data):
o = ConfigFile(oauth_path=oauth_file)
assert o.oauth_path.access_token == oauth_data[0]["access_token"]
o = ConfigFile(oauth_path=str(oauth_file))
assert o.oauth_path.__root__[0].access_token == oauth_data[0]["access_token"]

0 comments on commit 0ccff67

Please sign in to comment.