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 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 . 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"