Skip to content

Commit 21c03da

Browse files
committed
fix: field extraction error message
1 parent e706433 commit 21c03da

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

pytest_splunk_addon/standard_lib/requirement_tests/test_templates.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
import json
1617
import logging
1718
import pytest
1819
import re
@@ -50,7 +51,15 @@ def compare(self, keyValueSPL, keyValueXML, escapedKeyValue):
5051
for key, value in keyValueXML.items():
5152
res = key in keyValueprocessedSPL and value == keyValueprocessedSPL[key]
5253
if (not res) and (key not in escapedKeyValue):
53-
dict_missing_key_value.update({key: value})
54+
valueinsplunk = None
55+
if key in keyValueSPL.keys():
56+
valueinsplunk = keyValueSPL[key]
57+
dict_missing_key_value.update(
58+
{
59+
"Key value in requirement file: " + key: value,
60+
"Key value extracted by Splunk: " + key: valueinsplunk,
61+
}
62+
)
5463
flag = False
5564
return flag, dict_missing_key_value
5665

@@ -193,19 +202,13 @@ def test_requirement_params(
193202
keyValue_dict_SPL, key_values_xml, exceptions_dict
194203
)
195204
self.logger.info(f"Field mapping check: {field_extraction_check}")
196-
mismapped_key_value_pair = {}
197-
for key, value in missing_key_value.items():
198-
if key in keyValue_dict_SPL.keys():
199-
valueInSplunk = keyValue_dict_SPL[key]
200-
mismapped_key_value_pair.update({key: valueInSplunk})
201205

202206
assert datamodel_check and field_extraction_check, (
203207
f" Issue with either field extraction or data model.\nsearch={search}\n"
204208
f" data model check: {datamodel_check} \n"
205209
f" data model in requirement file {model_datalist}\n "
206210
f" data model extracted by TA {list(datamodel_based_on_tag.keys())}\n"
207211
f" Field_extraction_check: {field_extraction_check} \n"
208-
f" Key value not extracted by TA: {missing_key_value} \n"
209-
f" Mismatched key value: {mismapped_key_value_pair}\n"
212+
f" Field extraction errors: {json.dumps(missing_key_value, indent=4)}q \n"
210213
f" sourcetype of ingested event: {sourcetype} \n"
211214
)

0 commit comments

Comments
 (0)