Skip to content

Commit 0c2bcd2

Browse files
committed
test(spp_import_match): update conditional-match test for new pure-gate semantics (OP#991)
CI surfaced a regression in test_match_find_conditional_match. The test was written under the pre-OP#991 semantics where an `is_conditional=True` row contributed BOTH a gate (CSV value check) AND a search predicate (`field_id` added to the search domain). The OP#991 fix (commit da3f563) intentionally removes that dual role — conditional rows are now pure gates, never injected into the domain. Under the new semantics, a rule with only one conditional row produces an empty search domain and is skipped (the existing `if not domain: continue` guard at line 109). The test's assertion that the partner would be found is therefore obsolete. Rewrite the test to demonstrate the new gate + non-conditional-search shape: a conditional row gates on `name`, and a non-conditional row provides the actual `email` search predicate. Verifies the gate- passing path while respecting the OP#991 semantics. Sibling test test_match_find_conditional_skip (gate-failing path) still passes unchanged. 44 tests, 0 failed locally.
1 parent 7d7c879 commit 0c2bcd2

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

spp_import_match/tests/test_import_match_model.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,33 @@ def test_match_find_conditional_skip(self):
120120
self.assertFalse(result.id)
121121

122122
def test_match_find_conditional_match(self):
123-
"""Test _match_find uses rule when conditional value matches."""
124-
partner = self.env["res.partner"].create({"name": "ConditionalMatchTest"})
123+
"""Test _match_find applies the rule when the conditional gate passes.
124+
125+
Under OP#991 semantics, an `is_conditional=True` row is a pure gate —
126+
it decides whether the rule applies to this CSV row but is never
127+
added to the DB search domain (the gate column may be a CSV-only
128+
metadata field that doesn't exist on the registrant model). The
129+
combination must include at least one non-conditional row to
130+
provide the actual search predicate. Here `name` is the gate and
131+
`email` is the search predicate.
132+
"""
133+
partner = self.env["res.partner"].create(
134+
{"name": "ConditionalMatchTest", "email": "conditional@example.com"}
135+
)
125136
match = self._create_match_rule(
126137
[
127138
{
128139
"field_id": self.name_field.id,
129140
"is_conditional": True,
130141
"imported_value": "ConditionalMatchTest",
131-
}
142+
},
143+
{"field_id": self.email_field.id},
132144
]
133145
)
134146
result = match._match_find(
135147
self.env["res.partner"],
136-
{"name": "ConditionalMatchTest"},
137-
{"name": "ConditionalMatchTest", "id": None},
148+
{"email": "conditional@example.com"},
149+
{"name": "ConditionalMatchTest", "email": "conditional@example.com", "id": None},
138150
)
139151
self.assertEqual(result, partner)
140152

0 commit comments

Comments
 (0)