Skip to content

Commit fc708ba

Browse files
committed
tests: update repr expectations
1 parent 0e84d70 commit fc708ba

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

execution_engine/omop/concepts.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,10 @@ def __str__(self) -> str:
2323
"""
2424
Returns a string representation of the concept.
2525
"""
26-
base = f'OMOP Concept: "{self.concept_name}" ({self.concept_id}) [{self.vocabulary_id}#{self.concept_code}]'
26+
if self.vocabulary_id == "UCUM":
27+
return str(self.concept_code)
2728

28-
if self.standard_concept is not None and self.standard_concept == "S":
29-
return f"{base} (STANDARD)"
30-
31-
return base
32-
33-
# def __str__(self) -> str:
34-
# """
35-
# Returns a string representation of the concept.
36-
# """
37-
# if self.vocabulary_id == "UCUM":
38-
# return str(self.concept_code)
39-
#
40-
# return str(self.concept_name)
29+
return str(self.concept_name)
4130

4231
def is_custom(self) -> bool:
4332
"""

execution_engine/omop/criterion/combination/temporal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ class TimeIntervalType(StrEnum):
2020
DAY = "day"
2121
ANY_TIME = "any_time"
2222

23+
def __repr__(self) -> str:
24+
"""
25+
Get the string representation of the time interval type.
26+
"""
27+
return f'{self.__class__.__name__}("{self.value}")'
28+
2329

2430
class TemporalIndicatorCombination(CriterionCombination):
2531
"""

tests/execution_engine/converter/test_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_parse_value_codeable_concept(self, monkeypatch, test_concept):
9090
mock_get_standard_concept = MagicMock()
9191
mock_get_standard_concept.return_value = test_concept
9292
monkeypatch.setattr(
93-
"execution_engine.omop.vocabulary.standard_vocabulary.get_standard_concept",
93+
"execution_engine.omop.vocabulary.standard_vocabulary.get_concept",
9494
mock_get_standard_concept,
9595
)
9696

@@ -102,7 +102,7 @@ def test_parse_value_codeable_concept(self, monkeypatch, test_concept):
102102

103103
assert isinstance(value, ValueConcept)
104104
mock_get_standard_concept.assert_called_once_with(
105-
system_uri="http://example.com", concept="123"
105+
system_uri="http://example.com", concept="123", standard=True
106106
)
107107

108108
def test_parse_value_quantity(self, monkeypatch, unit_concept):

tests/execution_engine/omop/criterion/combination/test_logical_combination.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ def test_repr(self):
224224
category=CohortCategory.POPULATION_INTERVENTION,
225225
)
226226

227-
assert (
228-
repr(combination)
229-
== "LogicalCriterionCombination(AND).POPULATION_INTERVENTION"
230-
)
227+
assert repr(combination) == "LogicalCriterionCombination.And(\n)"
231228

232229
def test_add_all(self):
233230
operator = LogicalCriterionCombination.Operator(

tests/execution_engine/omop/criterion/combination/test_temporal_combination.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_repr(self):
214214

215215
assert (
216216
repr(combination)
217-
== "TemporalIndicatorCombination(AT_LEAST(threshold=1)).POPULATION_INTERVENTION for morning_shift"
217+
== 'TemporalIndicatorCombination(operator=Operator("AT_LEAST", threshold=1), category=CohortCategory.POPULATION_INTERVENTION, interval_type=TimeIntervalType("morning_shift"))'
218218
)
219219

220220
combination = TemporalIndicatorCombination(
@@ -226,7 +226,7 @@ def test_repr(self):
226226

227227
assert (
228228
repr(combination)
229-
== "TemporalIndicatorCombination(AT_LEAST(threshold=1)).POPULATION_INTERVENTION from 08:00:00 to 16:00:00"
229+
== 'TemporalIndicatorCombination(operator=Operator("AT_LEAST", threshold=1), category=CohortCategory.POPULATION_INTERVENTION, start_time=datetime.time(8, 0), end_time=datetime.time(16, 0))'
230230
)
231231

232232
def test_add_all(self):

tests/execution_engine/omop/test_concepts.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_str(self):
3333
standard_concept="S",
3434
invalid_reason=None,
3535
)
36-
assert str(concept) == concept.concept_name
36+
assert str(concept) == "Test Concept"
3737

3838
concept = Concept(
3939
concept_id=1,
@@ -45,7 +45,7 @@ def test_str(self):
4545
standard_concept="N",
4646
invalid_reason=None,
4747
)
48-
assert str(concept) == concept.concept_name
48+
assert str(concept) == "Test Concept"
4949

5050
def test_repr(self):
5151
concept = Concept(
@@ -60,7 +60,8 @@ def test_repr(self):
6060
)
6161
assert (
6262
repr(concept)
63-
== 'OMOP Concept: "Test Concept" (1) [Test Vocabulary#C123] (STANDARD)'
63+
== "Concept(concept_id=1, concept_name='Test Concept', concept_code='C123', domain_id='Test Domain', "
64+
"vocabulary_id='Test Vocabulary', concept_class_id='Test Class', standard_concept='S', invalid_reason=None)"
6465
)
6566

6667
def test_is_custom(self):

tests/execution_engine/util/test_value.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def test_repr(self, unit_concept):
132132
vn = ValueNumber(unit=unit_concept, value=5)
133133
assert (
134134
repr(vn)
135-
== """ValueNumber(unit=OMOP Concept: "Test Unit" (1) [test#unit], value=5.0, value_min=None, value_max=None)"""
135+
== """ValueNumber(unit=Concept(concept_id=1, concept_name='Test Unit', concept_code='unit', domain_id='units', vocabulary_id='test', concept_class_id='test', standard_concept=None, invalid_reason=None), value=5.0, value_min=None, value_max=None)"""
136136
)
137137

138138
def test_to_sql(self, unit_concept, test_table):
@@ -309,14 +309,14 @@ def test_str(self, test_concept):
309309
value_concept = ValueConcept(value=test_concept)
310310
assert (
311311
repr(value_concept)
312-
== 'Value == OMOP Concept: "Test Concept" (1) [test#unit]'
312+
== "Value == Concept(concept_id=1, concept_name='Test Concept', concept_code='unit', domain_id='units', vocabulary_id='test', concept_class_id='test', standard_concept=None, invalid_reason=None)"
313313
)
314314

315315
def test_repr(self, test_concept):
316316
value_concept = ValueConcept(value=test_concept)
317317
assert (
318318
repr(value_concept)
319-
== 'Value == OMOP Concept: "Test Concept" (1) [test#unit]'
319+
== "Value == Concept(concept_id=1, concept_name='Test Concept', concept_code='unit', domain_id='units', vocabulary_id='test', concept_class_id='test', standard_concept=None, invalid_reason=None)"
320320
)
321321

322322
def test_dict(self, test_concept):

0 commit comments

Comments
 (0)