def test_doesnt_update_queries_with_different_hash(self): query1 = self.factory.create_query(query_text=self.query) query2 = self.factory.create_query(query_text=self.query) query3 = self.factory.create_query(query_text=self.query + "123") query_result = QueryResult.store_result(self.data_source.org_id, self.data_source, self.query_hash, self.query, self.data, self.runtime, self.utcnow) Query.update_latest_result(query_result) self.assertEqual(query1.latest_query_data, query_result) self.assertEqual(query2.latest_query_data, query_result) self.assertNotEqual(query3.latest_query_data, query_result)
def test_updates_existing_queries(self): query1 = self.factory.create_query(query_text=self.query) query2 = self.factory.create_query(query_text=self.query) query3 = self.factory.create_query(query_text=self.query) query_result = QueryResult.store_result(self.data_source.org_id, self.data_source, self.query_hash, self.query, self.data, self.runtime, self.utcnow) Query.update_latest_result(query_result) self.assertEqual(query1.latest_query_data, query_result) self.assertEqual(query2.latest_query_data, query_result) self.assertEqual(query3.latest_query_data, query_result)