Skip to content

Commit

Permalink
Some test consolidation
Browse files Browse the repository at this point in the history
* fixed possibility to run single tests
* use full standard instead of fixture files for most tests
* download and cache standard in the CI
* fix to handle empty tag with type 1C as an error
* use lxml used instead of xml for xml parsing
  • Loading branch information
mrbean-bremen committed Oct 28, 2023
1 parent 90207ba commit e163b5d
Show file tree
Hide file tree
Showing 27 changed files with 174 additions and 13,482 deletions.
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

0 comments on commit e163b5d

Please sign in to comment.