From 6d8bf073c9a5f4dcab0149be450289f0c969378a Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 29 Jan 2025 16:11:36 -0800 Subject: [PATCH 1/3] add tests for inspect_url --- src/nwbinspector/_nwbinspector_cli.py | 2 +- tests/streaming_tests.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/nwbinspector/_nwbinspector_cli.py b/src/nwbinspector/_nwbinspector_cli.py index db42f5c64..2b16ce574 100644 --- a/src/nwbinspector/_nwbinspector_cli.py +++ b/src/nwbinspector/_nwbinspector_cli.py @@ -160,7 +160,7 @@ def _nwbinspector_cli( show_progress_bar=show_progress_bar, ) # Scan a single NWB file in a Dandiset - elif stream and ":" in path: + elif stream and ":" in path and not path_is_url: dandiset_id, dandi_file_path = path.split(":") dandiset_version = version_id diff --git a/tests/streaming_tests.py b/tests/streaming_tests.py index 2408ae675..df382410c 100644 --- a/tests/streaming_tests.py +++ b/tests/streaming_tests.py @@ -1,5 +1,7 @@ """Test the API functions related to streaming.""" +import os + import pytest from nwbinspector import ( @@ -104,3 +106,17 @@ def test_inspect_url(): ) assert test_message == expected_message + + +@pytest.mark.skipif(not STREAMING_TESTS_ENABLED, reason=DISABLED_STREAMING_TESTS_REASON or "") +def test_inspect_url_cli(tmp_path): + """Test that the CLI correctly handles inspecting a URL.""" + url = "https://dandiarchive.s3.amazonaws.com/blobs/11e/c89/11ec8933-1456-4942-922b-94e5878bb991" + console_output_file = tmp_path / "url_console_output.txt" + + os.system(f"nwbinspector {url} " "--skip-validate " f"> {console_output_file}") + + # Read and check the contents of the console output file + with open(console_output_file, "r") as file: + output = file.read() + assert "Subject species is missing." in output From 4d6a48257181a597af1f44ebea96c2c41ec654a3 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 29 Jan 2025 16:54:51 -0800 Subject: [PATCH 2/3] update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3e460188..702619e20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes * Fix wrongly triggered compression check [#552](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/552) +* Fixed URL inspection using the CLI [#559](https://github.com/NeurodataWithoutBorders/nwbinspector/issues/559) ## Improvements * Added a section for describing the issues with negative timestamps in `TimeSeries` [#545](https://github.com/NeurodataWithoutBorders/nwbinspector/pull/545) From e6f99ff1c5b47770334bd1a738de8654b2883699 Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Thu, 20 Feb 2025 13:48:01 -0800 Subject: [PATCH 3/3] move test to cli test file --- tests/streaming_cli_tests.py | 14 ++++++++++++++ tests/streaming_tests.py | 16 ---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/streaming_cli_tests.py b/tests/streaming_cli_tests.py index 7f116d0c8..82e97ee3d 100644 --- a/tests/streaming_cli_tests.py +++ b/tests/streaming_cli_tests.py @@ -120,3 +120,17 @@ def test_dandiset_streaming_cli_with_version_saved_report(tmpdir: py.path.local) expected_report_length = 38 report_end = report_start + expected_report_length assert test_report[report_start:report_end] == expected_report[14:] + + +@pytest.mark.skipif(not STREAMING_TESTS_ENABLED, reason=DISABLED_STREAMING_TESTS_REASON or "") +def test_inspect_url_cli(tmp_path): + """Test that the CLI correctly handles inspecting a URL.""" + url = "https://dandiarchive.s3.amazonaws.com/blobs/11e/c89/11ec8933-1456-4942-922b-94e5878bb991" + console_output_file = tmp_path / "url_console_output.txt" + + os.system(f"nwbinspector {url} " "--skip-validate " f"> {console_output_file}") + + # Read and check the contents of the console output file + with open(console_output_file, "r") as file: + output = file.read() + assert "Subject species is missing." in output diff --git a/tests/streaming_tests.py b/tests/streaming_tests.py index df382410c..2408ae675 100644 --- a/tests/streaming_tests.py +++ b/tests/streaming_tests.py @@ -1,7 +1,5 @@ """Test the API functions related to streaming.""" -import os - import pytest from nwbinspector import ( @@ -106,17 +104,3 @@ def test_inspect_url(): ) assert test_message == expected_message - - -@pytest.mark.skipif(not STREAMING_TESTS_ENABLED, reason=DISABLED_STREAMING_TESTS_REASON or "") -def test_inspect_url_cli(tmp_path): - """Test that the CLI correctly handles inspecting a URL.""" - url = "https://dandiarchive.s3.amazonaws.com/blobs/11e/c89/11ec8933-1456-4942-922b-94e5878bb991" - console_output_file = tmp_path / "url_console_output.txt" - - os.system(f"nwbinspector {url} " "--skip-validate " f"> {console_output_file}") - - # Read and check the contents of the console output file - with open(console_output_file, "r") as file: - output = file.read() - assert "Subject species is missing." in output