Skip to content

Commit

Permalink
connector_search_engine*: include update timestamp in data
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Jun 12, 2024
1 parent b2b624b commit 14d5836
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion connector_search_engine/models/se_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def recompute_json(self, force_export: bool = False):

def _recompute_data(self):
self.date_recomputed = fields.Datetime.now()
self.data = self.index_id.model_serializer.serialize(self.record)
data = self.index_id.model_serializer.serialize(self.record)
data["updated_on"] = fields.Datetime.to_string(self.date_recomputed)
self.data = data

def _validate_data(self):
self.index_id.json_validator.validate(self.data or {})
Expand Down
8 changes: 6 additions & 2 deletions connector_search_engine/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,16 @@ def test_archive_unarchive_record(self):
def test_recompute_one_record(self):
self.partner_binding.recompute_json()
self.assertEqual(self.partner_binding.state, "to_export")
self.assertEqual(self.partner_binding.get_export_data(), self.partner_expected)
data = self.partner_binding.get_export_data()
data.pop("updated_on")
self.assertEqual(data, self.partner_expected)
self.assertTrue(self.partner_binding.date_recomputed)

def test_recompute_all_indexes(self):
self.env["se.index"].recompute_all_index()
self.assertEqual(self.partner_binding.get_export_data(), self.partner_expected)
data = self.partner_binding.get_export_data()
data.pop("updated_on")
self.assertEqual(data, self.partner_expected)
self.assertEqual(self.partner_binding.state, "to_export")
self.assertTrue(self.partner_binding.date_recomputed)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ def test_changing_model_remove_exporter(self):

def test_serialize(self):
self.partner_binding.recompute_json()
data = self.partner_binding.data
data.pop("updated_on")
self.assertEqual(
self.partner_binding.data,
data,
{
"active": True,
"child_ids": [
Expand Down

0 comments on commit 14d5836

Please sign in to comment.