Skip to content

Commit

Permalink
Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
spearmin10 committed Jan 9, 2025
1 parent 608c655 commit f108d35
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Packs/XQLDSHelper/Scripts/XQLDSHelper/XQLDSHelper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,11 @@ def __get_list_from_content_bundle(
def __get_query_response(
self,
) -> Any:
if file_name := demisto.get(self.__config, 'xql.response'):
with open(file_name, 'r') as f:
response = demisto.get(self.__config, 'xql.response')
if isinstance(response, dict):
return response
elif isinstance(response, str):
with open(response, 'r') as f:
return json.loads(f.read())

raise RuntimeError((
Expand Down
226 changes: 226 additions & 0 deletions Packs/XQLDSHelper/Scripts/XQLDSHelper/test_data/test-others.json
Original file line number Diff line number Diff line change
Expand Up @@ -1141,5 +1141,231 @@
"latest_time": "2025-01-01T01:23:45.123+00:00"
}
}
},
"######### variable_substitution - default",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "${text}"
}
}
}
}
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "test message",
"Contents": null
}
}
},
"######### variable_substitution - custom enclosure",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "@{text}"
}
}
}
},
"variable_substitution": "@{,}"
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "test message",
"Contents": null
}
}
},
"######### variable_substitution - no closing marker",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "123 $text 456"
}
}
}
},
"variable_substitution": "$"
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "123 test message 456",
"Contents": null
}
}
},
"######### variable_substitution - overwritten by settings",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "@{text}"
}
},
"config": {
"variable_substitution": {
"opening": "@{",
"closing": "}"
}
}
}
},
"variable_substitution": "${,}"
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "test message",
"Contents": null
}
}
},
"######### variable_substitution - overwritten by settings (no config.variable_substitution.closing)",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "@{text}"
}
},
"config": {
"variable_substitution": {
"opening": "@{"
}
}
}
},
"variable_substitution": "${,}"
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "test message",
"Contents": null
}
}
},
"######### variable_substitution - overwritten by settings (config.variable_substitution.closing = empty)",
{
"args": {
"templates_type": "raw",
"template_name": "test",
"templates": {
"test": {
"query": {
"xql": "Dummy XQL"
},
"entry": {
"type": "markdown",
"markdown": {
"text": "123 @text 456"
}
},
"config": {
"variable_substitution": {
"opening": "@",
"closing": ""
}
}
}
},
"variable_substitution": "${,}"
},
"xql": {
"response": "./test_data/qr_duration.json"
},
"context": {
"text": "test message"
},
"results": {
"Entry": {
"Type": 1,
"ContentsFormat": "markdown",
"HumanReadable": "123 test message 456",
"Contents": null
}
}
}
]

0 comments on commit f108d35

Please sign in to comment.