Skip to content

Commit 7fa8b85

Browse files
committed
Tests/Snapshots: fix master record correlation hook tests
Test added by Copilot wasn't working. The issue was a conflict between the new and existing correlation hooks. Solved by adding new separate attributes.
1 parent 8840e94 commit 7fa8b85

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

tests/modules/test_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def __init__(
8888
# This hook should copy data1 from master record to data2 with a suffix
8989
registrar.register_correlation_hook_with_master_record(
9090
update_wrapper(
91-
partial(use_master_record, target_attr="data2", source_attr="data1"),
91+
partial(use_master_record, target_attr="data4", source_attr="data3"),
9292
use_master_record,
9393
),
9494
"A",
9595
depends_on=[],
96-
may_change=[["data2"]],
96+
may_change=[["data4"]],
9797
)

tests/test_api/test_snapshots.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def make_dp(type, id, attr, v, time=False):
4343
make_dp("C", "c1", "data1", "inita"),
4444
make_dp("C", "c1", "data2", "inita"),
4545
# For test_master_record_hook (A-423)
46-
make_dp("A", 423, "data1", "master_test"),
47-
make_dp("A", 423, "data2", "placeholder"),
46+
make_dp("A", 423, "data3", "master_test"),
47+
make_dp("A", 423, "data4", "placeholder"),
4848
]
4949
res = cls.push_datapoints(entity_datapoints)
5050
if res.status_code != 200:
@@ -93,6 +93,6 @@ def test_master_record_hook(self):
9393
data = self.get_entity_data("entity/A/423", EntityEidData)
9494
self.assertGreater(len(data.snapshots), 0)
9595
for snapshot in data.snapshots:
96-
self.assertEqual(snapshot["data1"], "master_test")
97-
# The hook should have set data2 to data1 from master record + "_from_master"
98-
self.assertEqual(snapshot["data2"], "master_test_from_master")
96+
self.assertEqual(snapshot["data3"], "master_test")
97+
# The hook should have set data4 to data3 from master record + "_from_master"
98+
self.assertEqual(snapshot["data4"], "master_test_from_master")

tests/test_config/db_entities/A.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ attribs:
1717
type: plain
1818
data_type: string
1919

20+
data3:
21+
name: data3
22+
description: entity data
23+
type: plain
24+
data_type: string
25+
26+
data4:
27+
name: data4
28+
description: entity data
29+
type: plain
30+
data_type: string
31+
2032
as:
2133
name: As
2234
description: Link to other A entities

0 commit comments

Comments
 (0)