|
10 | 10 | get_kb_matched_statements, |
11 | 11 | get_kb_statement_matched_conditions, |
12 | 12 | get_kb_variants, |
| 13 | + get_kb_matches_sections, |
13 | 14 | ) |
14 | 15 | from pori_python.types import Statement |
15 | 16 |
|
@@ -696,9 +697,12 @@ def test_partial_matches_omitted(self): |
696 | 697 | for item in input_fields: # we don't care about these for this test |
697 | 698 | item["variantType"] = "test" |
698 | 699 | item["kbVariant"] = "test" |
| 700 | + |
699 | 701 | gkb_matches = create_gkb_matches(input_fields) |
700 | | - stmts = get_kb_matched_statements(gkb_matches) |
701 | | - kbcs = get_kb_statement_matched_conditions(gkb_matches) |
| 702 | + sections = get_kb_matches_sections(gkb_matches, allow_partial_matches=False) |
| 703 | + |
| 704 | + stmts = sections['kbMatchedStatements'] |
| 705 | + kbcs = sections['kbStatementMatchedConditions'] |
702 | 706 | assert len(stmts) == 2 |
703 | 707 | assert len(kbcs) == 1 # X only |
704 | 708 | assert kbcs[0]["kbStatementId"] == "X" |
@@ -748,6 +752,53 @@ def test_partial_matches_omitted_even_when_var_used_elsewhere(self): |
748 | 752 | assert len(kbcs) == 2 # X and Z but not Y |
749 | 753 | assert "Y" not in [item["kbStatementId"] for item in kbcs] |
750 | 754 |
|
| 755 | + def test_kbvariants_removed_from_set_when_not_part_of_full_conditionset_match(self): |
| 756 | + """When there is a variant that fulfills one part of a statement's condition set, |
| 757 | + but isn't part of any fully satisfied condition set, |
| 758 | + the kbvariant record should be removed from the kbvariants list |
| 759 | + """ |
| 760 | + input_fields = [ |
| 761 | + { |
| 762 | + "variant": "A", |
| 763 | + "kbVariantId": "test1", |
| 764 | + "kbStatementId": "X", |
| 765 | + "requiredKbMatches": ["test1", "test2", "test3"], |
| 766 | + }, |
| 767 | + { |
| 768 | + "variant": "B", |
| 769 | + "kbVariantId": "test2", |
| 770 | + "kbStatementId": "X", |
| 771 | + "requiredKbMatches": ["test1", "test2", "test3"], |
| 772 | + }, |
| 773 | + { |
| 774 | + "variant": "A", |
| 775 | + "kbVariantId": "test1", |
| 776 | + "kbStatementId": "Y", |
| 777 | + "requiredKbMatches": ["test4", "test1"], |
| 778 | + }, |
| 779 | + { |
| 780 | + "variant": "D", |
| 781 | + "kbVariantId": "test4", |
| 782 | + "kbStatementId": "Y", |
| 783 | + "requiredKbMatches": ["test4", "test1"], |
| 784 | + }, |
| 785 | + ] |
| 786 | + for item in input_fields: # we don't care about these for this test |
| 787 | + item["variantType"] = "test" |
| 788 | + item["kbVariant"] = "test" |
| 789 | + gkb_matches = create_gkb_matches(input_fields) |
| 790 | + sections1 = get_kb_matches_sections(gkb_matches, allow_partial_matches=False) |
| 791 | + kbcs1 = sections1['kbStatementMatchedConditions'] |
| 792 | + kbvars1 = sections1['kbMatches'] |
| 793 | + assert len(kbcs1) == 1 # only fully matched condition sets included |
| 794 | + assert len(kbvars1) == 2 # therefore, kbvars associated with stmt X are pruned |
| 795 | + |
| 796 | + sections2 = get_kb_matches_sections(gkb_matches, allow_partial_matches=True) |
| 797 | + kbcs2 = sections2['kbStatementMatchedConditions'] |
| 798 | + kbvars2 = sections2['kbMatches'] |
| 799 | + assert len(kbcs2) == 2 # all condition sets included |
| 800 | + assert len(kbvars2) == 3 # therefore, no pruning |
| 801 | + |
751 | 802 | def test_partial_matches_included(self): |
752 | 803 | """check statements that are only partially supported |
753 | 804 | are included when allow_partial_matches=True""" |
|
0 commit comments