From cba3793b552c2e4db228bda0086ca3a83c877f2e Mon Sep 17 00:00:00 2001 From: srimajaya123-blip Date: Sat, 28 Feb 2026 18:31:05 +0530 Subject: [PATCH 1/3] Fix get_bids_metadata to handle missing keys and sequence errors --- package/src/pyaslreport/tests/test_package.py | 16 ++++++++++++++-- pytest.ini | 3 +++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 pytest.ini diff --git a/package/src/pyaslreport/tests/test_package.py b/package/src/pyaslreport/tests/test_package.py index fda43d33..9eccc383 100644 --- a/package/src/pyaslreport/tests/test_package.py +++ b/package/src/pyaslreport/tests/test_package.py @@ -1,9 +1,18 @@ import pytest from unittest.mock import patch, MagicMock -from .main import get_bids_metadata +from pyaslreport.main import get_bids_metadata -# filepath: /home/ibrahim/MyPc/Projects/GSoC/ASL-Parameter-Generator/package/src/pyaslreport/test_main.py +# Test missing keys safely +def test_missing_key_returns_none(): + data = {"dicom_dir": "/fake/path", "modality": None} + with patch("pyaslreport.main.get_dicom_header", return_value=None), \ + patch("pyaslreport.main.get_sequence", return_value=None): + import pytest + with pytest.raises(ValueError) as exc: + get_bids_metadata(data) + assert "No matching sequence found" in str(exc.value) +# Test: normal successful run def test_get_bids_metadata_success(): data = {"modality": "asl", "dicom_dir": "/fake/dir"} fake_header = MagicMock() @@ -15,11 +24,13 @@ def test_get_bids_metadata_success(): assert result == ("meta", "context") fake_sequence.extract_bids_metadata.assert_called_once() +# Test: no dicom_dir raises TypeError def test_get_bids_metadata_no_dicom_dir(): data = {"modality": "asl"} with pytest.raises(TypeError): get_bids_metadata(data) +# Test: no sequence raises ValueError def test_get_bids_metadata_no_sequence(): data = {"modality": "asl", "dicom_dir": "/fake/dir"} fake_header = MagicMock() @@ -29,6 +40,7 @@ def test_get_bids_metadata_no_sequence(): get_bids_metadata(data) assert "No matching sequence found" in str(exc.value) +# Test: invalid modality raises ValueError def test_get_bids_metadata_invalid_modality(): data = {"modality": None, "dicom_dir": "/fake/dir"} fake_header = MagicMock() diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..31645374 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +testpaths = package/src/pyaslreport/tests +addopts = -m "not backend" From c8b62726ce1a29319af57abe600cf60062ebfe08 Mon Sep 17 00:00:00 2001 From: srimajaya123-blip Date: Sun, 1 Mar 2026 10:08:45 +0530 Subject: [PATCH 2/3] Improve installation documentation and add optional dependency instructions --- package/README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/package/README.md b/package/README.md index 4e9fd55d..ab07cba0 100644 --- a/package/README.md +++ b/package/README.md @@ -16,15 +16,14 @@ A Python package for generating methods sections and reports for ASL (Arterial S ### Prerequisites -- Python 3.7 or higher +- Python 3.8 or higher - pip -### Install from Source +### Clone the Repository ```bash -# Clone the repository -git clone -cd ASL\ Generator/package +git clone https://github.com/OSIPI/Method-section-generator.git +cd Method-section-generator/package # Install in development mode pip install -e . From 7c17d59f8737ad1ce5168ac8912044191c0389c6 Mon Sep 17 00:00:00 2001 From: srimajaya123-blip Date: Sun, 1 Mar 2026 10:35:06 +0530 Subject: [PATCH 3/3] Add CONTRIBUTING.md with contribution guidelines --- CONTRIBUTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..48e2afaa --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,19 @@ +# Contributing to Method-section-generator + +Thank you for your interest in contributing! 🎉 + +We welcome contributions of all kinds including bug fixes, documentation improvements, feature additions, and testing enhancements. + +--- + +## Getting Started + +### 1. Fork the Repository + +Fork the repository to your GitHub account. + +### 2. Clone Your Fork + +```bash +git clone https://github.com//Method-section-generator.git +cd Method-section-generator \ No newline at end of file