Skip to content

Commit 6eca455

Browse files
Add failure scenario for calculate_levenshtein_distance
1 parent 196247a commit 6eca455

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

cumulusci/tasks/bulkdata/load.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ def configure_step(self, mapping):
342342
api_options["update_key"] = mapping.update_key[0]
343343
action = DataOperationType.UPSERT
344344
elif mapping.action == DataOperationType.SELECT:
345+
# Bulk process expects DataOpertionType to be QUERY
345346
action = DataOperationType.QUERY
346347
else:
347348
action = mapping.action

cumulusci/tasks/bulkdata/tests/test_select_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import pytest
2+
13
from cumulusci.tasks.bulkdata.select_utils import (
24
SelectOperationExecutor,
35
SelectStrategy,
@@ -215,6 +217,20 @@ def test_calculate_levenshtein_distance():
215217
assert calculate_levenshtein_distance(record1, record2) == 0 # Distance should be 0
216218

217219

220+
def test_calculate_levenshtein_distance_error():
221+
# Identical records
222+
record1 = ["Tom Cruise", "24", "Actor"]
223+
record2 = [
224+
"Tom Cruise",
225+
"24",
226+
"Actor",
227+
"SomethingElse",
228+
] # Record Length does not match
229+
with pytest.raises(ValueError) as e:
230+
calculate_levenshtein_distance(record1, record2)
231+
assert "Records must have the same number of fields" in str(e.value)
232+
233+
218234
def test_find_closest_record():
219235
# Test case 1: Exact match
220236
load_record = ["Tom Cruise", "62", "Actor"]

0 commit comments

Comments
 (0)