Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

More test fixes for patching in test suite #32

Merged
merged 1 commit into from
Feb 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"version": "draft",
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.4/context.json",
"citation": "Aguillon-Rodriguez, Valeria; Angelaki, Dora E.; Bayer, Hannah M.; Bonacchi, Niccol\u00f2; Carandini, Matteo; Cazettes, Fanny; Chapuis, Gaelle A.; Churchland, Anne K.; Dan, Yang; Dewitt, Eric E. J.; Faulkner, Mayo; Forrest, Hamish; Haetzel, Laura M.; Hausser, Michael; Hofer, Sonja B.; Hu, Fei; Khanal, Anup; Krasniak, Christopher S.; Laranjeira, In\u00eas; Mainen, Zachary F.; Meijer, Guido T.; Miska, Nathaniel J.; Mrsic-Flogel, Thomas D.; Murakami, Masayoshi; Noel, Jean-Paul; Pan-Vazquez, Alejandro; Rossant, Cyrille; Sanders, Joshua I.; Socha, Karolina Z.; Terry, Rebecca; Urai, Anne E.; Vergara, Hernando M.; Wells, Miles J.; Wilson, Christian J.; Witten, Ilana B.; Wool, Lauren E.; Zador, Anthony (2023) Standardized and reproducible measurement of decision-making in mice (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000001/draft",
"citation": "Aguillon-Rodriguez, Valeria; Angelaki, Dora E.; Bayer, Hannah M.; Bonacchi, Niccol\u00f2; Carandini, Matteo; Cazettes, Fanny; Chapuis, Gaelle A.; Churchland, Anne K.; Dan, Yang; Dewitt, Eric E. J.; Faulkner, Mayo; Forrest, Hamish; Haetzel, Laura M.; Hausser, Michael; Hofer, Sonja B.; Hu, Fei; Khanal, Anup; Krasniak, Christopher S.; Laranjeira, In\u00eas; Mainen, Zachary F.; Meijer, Guido T.; Miska, Nathaniel J.; Mrsic-Flogel, Thomas D.; Murakami, Masayoshi; Noel, Jean-Paul; Pan-Vazquez, Alejandro; Rossant, Cyrille; Sanders, Joshua I.; Socha, Karolina Z.; Terry, Rebecca; Urai, Anne E.; Vergara, Hernando M.; Wells, Miles J.; Wilson, Christian J.; Witten, Ilana B.; Wool, Lauren E.; Zador, Anthony (2024) Standardized and reproducible measurement of decision-making in mice (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000001/draft",
"schemaKey": "Dandiset",
"identifier": "DANDI:000001",
"repository": "http://localhost:8085",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"version": "draft",
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.4/context.json",
"citation": "Chowdhury, Raeed H; Glaser, Joshua I; Miller, Lee E (2023) Area 2 of primary somatosensory cortex encodes kinematics of the whole arm (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000004/draft",
"citation": "Chowdhury, Raeed H; Glaser, Joshua I; Miller, Lee E (2024) Area 2 of primary somatosensory cortex encodes kinematics of the whole arm (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000004/draft",
"schemaKey": "Dandiset",
"identifier": "DANDI:000004",
"repository": "http://localhost:8085",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"version": "draft",
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.4/context.json",
"citation": "Ito, Makoto; Doya, Kenji (2023) Validation of Decision-Making Models and Analysis of Decision Variables in the Rat Basal Ganglia (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000002/draft",
"citation": "Ito, Makoto; Doya, Kenji (2024) Validation of Decision-Making Models and Analysis of Decision Variables in the Rat Basal Ganglia (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000002/draft",
"schemaKey": "Dandiset",
"identifier": "DANDI:000002",
"repository": "http://localhost:8085",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"version": "draft",
"@context": "https://raw.githubusercontent.com/dandi/schema/master/releases/0.6.4/context.json",
"citation": "Sit, Kevin K.; Goard, Michael J. (2023) Coregistration of heading to visual cues in retrosplenial cortex (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000005/draft",
"citation": "Sit, Kevin K.; Goard, Michael J. (2024) Coregistration of heading to visual cues in retrosplenial cortex (Version draft) [Data set]. DANDI archive. http://localhost:8085/dandiset/000005/draft",
"schemaKey": "Dandiset",
"identifier": "DANDI:000005",
"repository": "http://localhost:8085",
Expand Down
18 changes: 9 additions & 9 deletions lincbrain/cli/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def test_download_defaults(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(download)
assert r.exit_code == 0
mock_download.assert_called_once_with(
Expand All @@ -29,7 +29,7 @@ def test_download_defaults(mocker):


def test_download_all_types(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(download, ["--download", "all"])
assert r.exit_code == 0
mock_download.assert_called_once_with(
Expand All @@ -47,7 +47,7 @@ def test_download_all_types(mocker):


def test_download_metadata_only(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(download, ["--download", "dandiset.yaml"])
assert r.exit_code == 0
mock_download.assert_called_once_with(
Expand All @@ -65,7 +65,7 @@ def test_download_metadata_only(mocker):


def test_download_assets_only(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(download, ["--download", "assets"])
assert r.exit_code == 0
mock_download.assert_called_once_with(
Expand All @@ -83,7 +83,7 @@ def test_download_assets_only(mocker):


def test_download_bad_type(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(download, ["--download", "foo"], standalone_mode=False)
assert r.exit_code != 0
assert isinstance(r.exception, click.UsageError)
Expand All @@ -95,7 +95,7 @@ def test_download_bad_type(mocker):


def test_download_gui_instance_in_dandiset(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
runner = CliRunner()
with runner.isolated_filesystem():
Path(dandiset_metadata_file).write_text("identifier: '123456'\n")
Expand All @@ -120,7 +120,7 @@ def test_download_gui_instance_in_dandiset(mocker):
reason="this instance now has GUI URL",
)
def test_download_api_instance_in_dandiset(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
runner = CliRunner()
with runner.isolated_filesystem():
Path(dandiset_metadata_file).write_text("identifier: '123456'\n")
Expand All @@ -141,7 +141,7 @@ def test_download_api_instance_in_dandiset(mocker):


def test_download_url_instance_match(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(
download,
[
Expand All @@ -166,7 +166,7 @@ def test_download_url_instance_match(mocker):


def test_download_url_instance_conflict(mocker):
mock_download = mocker.patch("dandi.download.download")
mock_download = mocker.patch("lincbrain.download.download")
r = CliRunner().invoke(
download,
["-i", "dandi", "http://localhost:8000/api/dandisets/123456/"],
Expand Down
4 changes: 2 additions & 2 deletions lincbrain/cli/tests/test_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@
def test_move_command(
mocker: MockerFixture, cmdline: list[str], srcs: list[str], kwargs: dict[str, Any]
) -> None:
mock_move = mocker.patch("dandi.move.move")
mock_move = mocker.patch("lincbrain.move.move")
r = CliRunner().invoke(move, cmdline)
assert r.exit_code == 0
mock_move.assert_called_once_with(*srcs, **kwargs)


def test_move_command_too_few_paths(mocker: MockerFixture) -> None:
mock_move = mocker.patch("dandi.move.move")
mock_move = mocker.patch("lincbrain.move.move")
r = CliRunner().invoke(move, ["foo"], standalone_mode=False)
assert r.exit_code != 0
# This is a ClickException when map_to_click_exceptions is in effect and a
Expand Down
2 changes: 1 addition & 1 deletion lincbrain/support/digests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .threaded_walk import threaded_walk
from ..utils import Hasher, exclude_from_zarr

lgr = logging.getLogger("dandi.support.digests")
lgr = logging.getLogger("lincbrain.support.digests")


@dataclass
Expand Down
14 changes: 7 additions & 7 deletions lincbrain/tests/test_dandiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def test_authenticate_bad_key_good_key_input(

backend_mock = mocker.Mock(spec=["set_password"])
keyring_lookup_mock = mocker.patch(
"dandi.dandiapi.keyring_lookup", return_value=(backend_mock, None)
"lincbrain.dandiapi.keyring_lookup", return_value=(backend_mock, None)
)
input_mock = mocker.patch("dandi.dandiapi.input", side_effect=[bad_key, good_key])
input_mock = mocker.patch("lincbrain.dandiapi.input", side_effect=[bad_key, good_key])
is_interactive_mock = mocker.patch(
"dandi.dandiapi.is_interactive", return_value=True
"lincbrain.dandiapi.is_interactive", return_value=True
)
confirm_mock = mocker.patch("click.confirm", return_value=True)

Expand Down Expand Up @@ -156,7 +156,7 @@ def test_authenticate_good_key_keyring(

backend_mock = mocker.Mock(spec=["set_password"])
keyring_lookup_mock = mocker.patch(
"dandi.dandiapi.keyring_lookup", return_value=(backend_mock, good_key)
"lincbrain.dandiapi.keyring_lookup", return_value=(backend_mock, good_key)
)
input_spy = mocker.spy(builtins, "input")
is_interactive_spy = mocker.spy(dandiapi, "is_interactive")
Expand Down Expand Up @@ -186,11 +186,11 @@ def test_authenticate_bad_key_keyring_good_key_input(

backend_mock = mocker.Mock(spec=["set_password"])
keyring_lookup_mock = mocker.patch(
"dandi.dandiapi.keyring_lookup", return_value=(backend_mock, bad_key)
"lincbrain.dandiapi.keyring_lookup", return_value=(backend_mock, bad_key)
)
input_mock = mocker.patch("dandi.dandiapi.input", return_value=good_key)
input_mock = mocker.patch("lincbrain.dandiapi.input", return_value=good_key)
is_interactive_mock = mocker.patch(
"dandi.dandiapi.is_interactive", return_value=True
"lincbrain.dandiapi.is_interactive", return_value=True
)
confirm_mock = mocker.patch("click.confirm", return_value=True)

Expand Down
10 changes: 5 additions & 5 deletions lincbrain/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_download_sync(
dspath = tmp_path / text_dandiset.dandiset_id
os.rename(text_dandiset.dspath, dspath)
confirm_mock = mocker.patch(
"dandi.download.abbrev_prompt", return_value="yes" if confirm else "no"
"lincbrain.download.abbrev_prompt", return_value="yes" if confirm else "no"
)
download(
f"dandi://{text_dandiset.api.instance_id}/{text_dandiset.dandiset_id}",
Expand All @@ -238,7 +238,7 @@ def test_download_sync_folder(
) -> None:
text_dandiset.dandiset.get_asset_by_path("file.txt").delete()
text_dandiset.dandiset.get_asset_by_path("subdir2/banana.txt").delete()
confirm_mock = mocker.patch("dandi.download.abbrev_prompt", return_value="yes")
confirm_mock = mocker.patch("lincbrain.download.abbrev_prompt", return_value="yes")
download(
f"dandi://{text_dandiset.api.instance_id}/{text_dandiset.dandiset_id}/subdir2/",
text_dandiset.dspath,
Expand All @@ -259,7 +259,7 @@ def test_download_sync_list(
text_dandiset.dandiset.get_asset_by_path("file.txt").delete()
dspath = tmp_path / text_dandiset.dandiset_id
os.rename(text_dandiset.dspath, dspath)
input_mock = mocker.patch("dandi.utils.input", side_effect=["list", "yes"])
input_mock = mocker.patch("lincbrain.utils.input", side_effect=["list", "yes"])
download(
f"dandi://{text_dandiset.api.instance_id}/{text_dandiset.dandiset_id}",
tmp_path,
Expand All @@ -280,7 +280,7 @@ def test_download_sync_zarr(
zarr_dandiset.dandiset.get_asset_by_path("sample.zarr").delete()
dspath = tmp_path / zarr_dandiset.dandiset_id
os.rename(zarr_dandiset.dspath, dspath)
confirm_mock = mocker.patch("dandi.download.abbrev_prompt", return_value="yes")
confirm_mock = mocker.patch("lincbrain.download.abbrev_prompt", return_value="yes")
download(
zarr_dandiset.dandiset.version_api_url,
tmp_path,
Expand Down Expand Up @@ -856,7 +856,7 @@ def test_download_sync_glob(
) -> None:
text_dandiset.dandiset.get_asset_by_path("file.txt").delete()
text_dandiset.dandiset.get_asset_by_path("subdir2/banana.txt").delete()
confirm_mock = mocker.patch("dandi.download.abbrev_prompt", return_value="yes")
confirm_mock = mocker.patch("lincbrain.download.abbrev_prompt", return_value="yes")
download(
f"{text_dandiset.dandiset.version_api_url}assets/?glob=s*.Txt",
text_dandiset.dspath,
Expand Down
8 changes: 4 additions & 4 deletions lincbrain/tests/test_keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_dandi_authenticate_no_env_var(
monkeypatch.delenv("DANDI_API_KEY", raising=False)
monkeypatch.setenv("PYTHON_KEYRING_BACKEND", "keyring.backends.null.Keyring")
inputmock = mocker.patch(
"dandi.dandiapi.input", return_value=local_dandi_api.api_key
"lincbrain.dandiapi.input", return_value=local_dandi_api.api_key
)
DandiAPIClient(local_dandi_api.api_url).dandi_authenticate()
inputmock.assert_called_once_with(
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_keyring_lookup_default_no_password(
) -> None:
monkeypatch.delenv("PYTHON_KEYRING_BACKEND", raising=False)
kb0 = null.Keyring()
get_keyring = mocker.patch("dandi.keyring.get_keyring", return_value=kb0)
get_keyring = mocker.patch("lincbrain.keyring.get_keyring", return_value=kb0)
kb, password = keyring_lookup("testservice", "testusername")
assert kb is kb0
assert password is None
Expand All @@ -159,7 +159,7 @@ def test_keyring_lookup_default_password(
monkeypatch.delenv("PYTHON_KEYRING_BACKEND", raising=False)
kb0 = keyfile.PlaintextKeyring()
kb0.set_password("testservice", "testusername", "testpassword")
get_keyring = mocker.patch("dandi.keyring.get_keyring", return_value=kb0)
get_keyring = mocker.patch("lincbrain.keyring.get_keyring", return_value=kb0)
kb, password = keyring_lookup("testservice", "testusername")
assert kb is kb0
assert password == "testpassword"
Expand All @@ -176,7 +176,7 @@ def test_keyring_lookup_fail_default_encrypted(
) -> None:
monkeypatch.delenv("PYTHON_KEYRING_BACKEND", raising=False)
get_keyring = mocker.patch(
"dandi.keyring.get_keyring", return_value=EncryptedFailure()
"lincbrain.keyring.get_keyring", return_value=EncryptedFailure()
)
with pytest.raises(KeyringError):
keyring_lookup("testservice", "testusername")
Expand Down
Loading