Beispiel #1
0
    def test_doesnt_update_queries_with_different_data_source(self):
        query1 = query_factory.create(query=self.query, data_source=self.data_source)
        query2 = query_factory.create(query=self.query, data_source=self.data_source)
        query3 = query_factory.create(query=self.query, data_source=data_source_factory.create())

        query_result_id = data_manager.store_query_result(self.data_source.id, self.query,
                                                          self.data, self.runtime, self.utcnow)

        self.assertEqual(models.Query.get_by_id(query1.id)._data['latest_query_data'], query_result_id)
        self.assertEqual(models.Query.get_by_id(query2.id)._data['latest_query_data'], query_result_id)
        self.assertNotEqual(models.Query.get_by_id(query3.id)._data['latest_query_data'], query_result_id)
Beispiel #2
0
    def test_stores_the_result(self):
        query_result_id = data_manager.store_query_result(self.data_source.id, self.query,
                                                          self.data, self.runtime, self.utcnow)

        query_result = models.QueryResult.get_by_id(query_result_id)

        self.assertEqual(query_result.data, self.data)
        self.assertEqual(query_result.runtime, self.runtime)
        self.assertEqual(query_result.retrieved_at, self.utcnow)
        self.assertEqual(query_result.query, self.query)
        self.assertEqual(query_result.query_hash, self.query_hash)
        self.assertEqual(query_result.data_source, self.data_source)
Beispiel #3
0
    def test_stores_the_result(self):
        query_result_id = data_manager.store_query_result(
            self.data_source.id, self.query, self.data, self.runtime,
            self.utcnow)

        query_result = models.QueryResult.get_by_id(query_result_id)

        self.assertEqual(query_result.data, self.data)
        self.assertEqual(query_result.runtime, self.runtime)
        self.assertEqual(query_result.retrieved_at, self.utcnow)
        self.assertEqual(query_result.query, self.query)
        self.assertEqual(query_result.query_hash, self.query_hash)
        self.assertEqual(query_result.data_source, self.data_source)
Beispiel #4
0
    def test_doesnt_update_queries_with_different_data_source(self):
        query1 = query_factory.create(query=self.query,
                                      data_source=self.data_source)
        query2 = query_factory.create(query=self.query,
                                      data_source=self.data_source)
        query3 = query_factory.create(query=self.query,
                                      data_source=data_source_factory.create())

        query_result_id = data_manager.store_query_result(
            self.data_source.id, self.query, self.data, self.runtime,
            self.utcnow)

        self.assertEqual(
            models.Query.get_by_id(query1.id)._data['latest_query_data'],
            query_result_id)
        self.assertEqual(
            models.Query.get_by_id(query2.id)._data['latest_query_data'],
            query_result_id)
        self.assertNotEqual(
            models.Query.get_by_id(query3.id)._data['latest_query_data'],
            query_result_id)