Skip to content

Commit

Permalink
CU-8694pz44d: Add a few more tests for report/results
Browse files Browse the repository at this point in the history
  • Loading branch information
mart-r committed Aug 20, 2024
1 parent 6098fa5 commit f6498ae
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions tests/utils/regression/test_checking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from medcat.utils.regression.targeting import OptionSet, FinalTarget
from medcat.utils.regression.targeting import TranslationLayer
from medcat.utils.regression.checking import RegressionSuite, RegressionCase, MetaData
from medcat.utils.regression.results import Finding, ResultDescriptor
from medcat.utils.regression.results import Finding, ResultDescriptor, Strictness

EXAMPLE_CUI = '123'
COMPLEX_PLACEHOLDERS = [
Expand Down Expand Up @@ -198,6 +198,16 @@ def test_specific_case_CUI(self):
+ self.EXPECT_MANUAL_SUCCESS # NOTE: manually added parts / success
)

def test_success_correct(self):
manual = self.get_manual_success()
report = self.res.calculate_report(strictness=Strictness.LENIENT)
self.assertEqual(report[1], manual)

def test_fail_correct(self):
manual = self.get_manual_fail()
report = self.res.calculate_report(strictness=Strictness.LENIENT)
self.assertEqual(report[2], manual)

def get_manual_success(self) -> int:
return sum(v for f, v in self.res.findings.items() if f not in self.FAIL_FINDINGS)

Expand Down Expand Up @@ -239,12 +249,12 @@ def test_result_is_json_serialisable_pydantic(self):

def test_can_use_strictness(self):
e1 = [
example for part in self.res.dict(strictness='STRICTEST')['parts']
example for part in self.res.dict(strictness=Strictness.STRICTEST)['parts']
for per_phrase in part['per_phrase_results'].values()
for example in per_phrase['examples']
]
e2 = [
example for part in self.res.dict(strictness='LENIENT')['parts']
example for part in self.res.dict(strictness=Strictness.LENIENT)['parts']
for per_phrase in part['per_phrase_results'].values()
for example in per_phrase['examples']
]
Expand Down

0 comments on commit f6498ae

Please sign in to comment.