From 4c2adb3bc2979ce7f645113bb0a2f41320e60cd7 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Sat, 9 Nov 2024 12:05:01 +0100 Subject: [PATCH 1/2] test: Add test with query status messages --- tests/test_client.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index 071cb35..c161bdc 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -174,6 +174,25 @@ def test_step005_apl_query(self): self.assertEqual(len(qr.matches), len(self.events)) + def test_step005_apl_query_messages(self): + """Test an APL query with messages""" + startTime = datetime.utcnow() - timedelta(minutes=2) + endTime = datetime.utcnow() + + apl = "['%s'] | where true" % self.dataset_name + opts = AplOptions( + start_time=startTime, + end_time=endTime, + format=AplResultFormat.Legacy, + ) + qr = self.client.query(apl, opts) + # "where clause always evaluates to TRUE, which will include all data" + self.assertEqual(len(qr.status.messages), 1) + self.assertEqual( + qr.status.messages[0].msg, + "line: 1, col: 24: where clause always evaluates to TRUE, which will include all data", + ) + def test_step005_apl_query_tabular(self): """Test apl query (tabular)""" # query the events we ingested in step2 From b702c4af2b306c33fa8439043d80fea6af8eee64 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Mon, 11 Nov 2024 13:14:18 +0100 Subject: [PATCH 2/2] test: Add an assert for the message code --- tests/test_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_client.py b/tests/test_client.py index c161bdc..e3975d6 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -192,6 +192,10 @@ def test_step005_apl_query_messages(self): qr.status.messages[0].msg, "line: 1, col: 24: where clause always evaluates to TRUE, which will include all data", ) + self.assertEqual( + qr.status.messages[0].code, + "apl_whereclausealwaysevaluatestoTRUEwhichwillincludealldata_1", + ) def test_step005_apl_query_tabular(self): """Test apl query (tabular)"""