-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathtest_local_gcp.py
More file actions
56 lines (41 loc) · 1.7 KB
/
test_local_gcp.py
File metadata and controls
56 lines (41 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import pytest
from globus_sdk import GlobusSDKUsageError, LocalGlobusConnectPersonal
@pytest.fixture
def pretend_is_windows(monkeypatch):
"""Patch LocalGlobusConnectPersonal to think it's on Windows
*even if it isn't*.
"""
monkeypatch.setattr(
"globus_sdk.local_endpoint.personal.endpoint._on_windows", lambda: True
)
@pytest.fixture
def pretend_is_not_windows(monkeypatch):
"""Patch LocalGlobusConnectPersonal to think it's NOT on Windows
*even if it is*.
"""
monkeypatch.setattr(
"globus_sdk.local_endpoint.personal.endpoint._on_windows", lambda: False
)
def test_windows_config_dir_requires_localappdata(pretend_is_windows, monkeypatch):
monkeypatch.delenv("LOCALAPPDATA", raising=False)
gcp = LocalGlobusConnectPersonal()
with pytest.raises(GlobusSDKUsageError):
gcp.config_dir
def test_windows_config_dir_ignores_localappdata_with_explicit_init(
pretend_is_windows, monkeypatch
):
monkeypatch.delenv("LOCALAPPDATA", raising=False)
gcp = LocalGlobusConnectPersonal(config_dir="/foo/bar")
assert gcp.config_dir == "/foo/bar"
def test_windows_default_config_dir(pretend_is_windows, monkeypatch, tmp_path):
monkeypatch.setenv("LOCALAPPDATA", str(tmp_path))
gcp = LocalGlobusConnectPersonal()
assert gcp.config_dir == str(tmp_path / "Globus Connect")
def test_nonwindows_default_config_dir(pretend_is_not_windows, monkeypatch, tmp_path):
def _fake_expanduser(p: str):
assert p.startswith("~/")
return str(tmp_path / p[2:])
monkeypatch.setattr(os.path, "expanduser", _fake_expanduser)
gcp = LocalGlobusConnectPersonal()
assert gcp.config_dir == str(tmp_path / ".globusonline")