Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some test consolidation #56

Merged
merged 1 commit into from
Oct 29, 2023
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
26 changes: 26 additions & 0 deletions .github/workflows/get_revision.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import argparse

from dicom_validator.spec_reader.edition_reader import EditionReader


def get_revision(revision, path):
reader = EditionReader(path)
# we want to recreate the json files for each test run
# so we don't want them cached
reader.get_revision(revision, create_json=False)


if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Downloads a revision of the DICOM standard"
)
parser.add_argument(
"revision",
help="Standard revision",
)
parser.add_argument(
"path",
help="Path for the DICOM specs",
)
args = parser.parse_args()
get_revision(args.revision, args.path)
17 changes: 17 additions & 0 deletions .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,33 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
dicom-version: ["2023c"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install -e .

- name: Cache DICOM standard
id: cache-dicom
uses: actions/cache@v3
with:
path: dicom_validator/test/fixtures
key: ${{ matrix.dicom-version }}

- name: Download DICOM standard
if: steps.cache-dicom.outputs.cache-hit != 'true'
run: |
pip install -e .
python .github/workflows/get_revision.py ${{ matrix.dicom-version }} "`pwd`/dicom_validator/tests/fixtures"

- name: Run tests with coverage
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-latest' && '${{ matrix.python-version }}' == '3.10' ]]
Expand All @@ -33,6 +49,7 @@ jobs:
else
python -m pytest dicom_validator
fi

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ success() && matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }}
Expand Down
11 changes: 10 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ The released versions correspond to PyPi releases.
### Features
* added handling of conditional includes (needed for SR documents)
(see [#39](../.. /issues/39))

### Fixes
* an empty tag with type 1C was not handled as an error

### Changes
* `lxml` is used instead of `xml` to speedup the xml parsing

### Infrastructure
* use `pyproject.toml` instead of `setup.py`
* use `pyproject.toml` instead of `setup.py`
* fixed possibility to run single tests
* use downloaded standard instead of fixture files for tests

## [Version 0.4.0](https://pypi.python.org/pypi/dicom-validator/0.4.0) (2023-08-13)
Adds support for functional group macros.
Expand Down
4 changes: 2 additions & 2 deletions dicom_validator/spec_reader/edition_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_json_files(cls, docbook_path, json_path):
cls.write_current_version(json_path)
print("Done!")

def get_revision(self, revision, recreate_json=False):
def get_revision(self, revision, recreate_json=False, create_json=True):
revision, destination = self.check_revision(revision)
if destination is None:
self.logger.error(f"DICOM revision {revision} not found.")
Expand All @@ -236,7 +236,7 @@ def get_revision(self, revision, recreate_json=False):
):
return

if (
if create_json and (
not self.json_files_exist(json_path)
or not self.is_current_version(json_path)
or recreate_json
Expand Down
5 changes: 4 additions & 1 deletion dicom_validator/spec_reader/spec_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
provided by ACR-NEMA.
"""

import xml.etree.ElementTree as ElementTree
try:
import lxml.etree as ElementTree
except ImportError:
import xml.etree.ElementTree as ElementTree
from pathlib import Path


Expand Down
128 changes: 0 additions & 128 deletions dicom_validator/tests/fixtures/2021d/json/dict_info.json

This file was deleted.

Loading