Skip to content

Commit

Permalink
Fix handling of unverifiable and condition
Browse files Browse the repository at this point in the history
- caused false positives
- fixes #32
  • Loading branch information
mrbean-bremen committed Aug 8, 2023
1 parent c03b372 commit 549cfb7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
python -m pytest dicom_validator
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
if: ${{ success() && matrix.python-version == 3.9 && matrix.os == 'ubuntu-latest' }}
with:
name: codecov-dicom-validator
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ The released versions correspond to PyPi releases.
### Features
* added initial support for validating functional group macros

### Fixes
* fixes handling of unverifiable and condition, see [#32](../.. /issues/32)

### Infrastructure
* Added pre-commit configuration for use with pre-commit hook

Expand Down
4 changes: 4 additions & 0 deletions dicom_validator/spec_reader/condition_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def _parse_tag_expressions(self, condition: str, nested: bool = False) -> Condit
cond_list.append(next_result)
result.type = None
result = new_result
elif logical_op == "and":
# the second part of the condition could not be parsed
# this invalidates the whole condition
result = next_result
if not nested and rest is not None:
other_cond = self._get_other_condition(rest)
if other_cond is not None and other_cond.type != "U":
Expand Down
12 changes: 10 additions & 2 deletions dicom_validator/tests/spec_reader/test_condition_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,24 @@ def test_and_condition(self, parser):
assert result2.operator == "="
assert result2.values == ["Y"]

def test_ignore_unverifyable_and_condition(self, parser):
def test_ignore_unverifyable_or_condition(self, parser):
result = parser.parse(
"Required if Delivery Type (300A,00CE) is CONTINUATION and "
"Required if Delivery Type (300A,00CE) is CONTINUATION or "
"one or more channels of any Application Setup are omitted."
)
assert result.type == "MN"
assert len(result.and_conditions) == 0
assert result.operator == "="
assert result.values == ["CONTINUATION"]

def test_unverifyable_and_condition_invalidates_condition(self, parser):
result = parser.parse(
"Required if Delivery Type (300A,00CE) is CONTINUATION and "
"one or more channels of any Application Setup are omitted."
)
assert result.type == "U"
assert result.tag is None

def test_and_without_value(self, parser):
result = parser.parse(
"Required if Recorded Channel Sequence (3008,0130) is sent and "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def validator(iod_info, module_info, request):
{
"CodeValue": "T-D3000",
"CodingSchemeDesignator": "SRT",
"CodingSchemeVersion": "1",
"CodeMeaning": "Chest",
}
],
Expand Down

0 comments on commit 549cfb7

Please sign in to comment.