Scroll ignore | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||
In addition to the Python functions described in Functions, Exceptions, Types, and Constants, the following functions are available for Unit Tests.
does not include any native assert functionality, this functionality can be found in the common python libraries. Add the Python Module and use in the unit test.
Note |
---|
Note! To access the Unit Test functions described below from a Python Module you can import the testkit module. This is useful when you write test-related helper functions. |
Finalizers
addFinalizer
This function adds a finalizer function to be called at scope exit.
Code Block | ||
---|---|---|
| ||
def addFinalizer(func, *args, **kwargs) |
Parameter | Description |
---|---|
func | A function |
*args | Positional arguments to be passed to the function |
**kwargs | Keyword arguments to be passed to the function |
Returns | An object with a remove() method |
Info | |||||
---|---|---|---|---|---|
Example - addFinalizer
|
finalizers
A Python context manager that defines an extra finalization scope. There are two pre-defined finalization scopes; one on the module level and one for each test function. These two scopes should be enough for normal use.
Info | |||||
---|---|---|---|---|---|
Example - finalizers
|
Conditional testing
SkipException
Tests can be skipped by raising the SkipException exception in the test function blocks, or the initialize function block.
Code Block | ||
---|---|---|
| ||
class SkipException(message=None) |
Parameter | Type |
---|---|
message | str |
Info | |||||
---|---|---|---|---|---|
Example - SkipException
|
Log functions
logSearch
Searches for entries in the System Log matching the given criteria. Returns an iterator with all matching entries.
Code Block | ||
---|---|---|
| ||
def logSearch(fromDate=None, toDate=None, severities=None, areas=None, wfName=None, wfGroupName=None, agentName=None, userName=None, message=None) |
Parameter | Type |
---|---|
fromDate | drdate |
toDate | drdate |
severities | list[str] |
areas | list[str] |
wfName | str |
wfGroupName | str |
agentName | str |
userName | str |
message | str |
Info | |||||
---|---|---|---|---|---|
Example - logSearch
|
logRemove
Removes the log entry with the specified id.
Code Block | ||
---|---|---|
| ||
def logRemove(id) |
Parameter | Type |
---|---|
id | str |
Workflow functions
These functions are event driven, meaning that an event is fired when the function is called. This means that if you use wfStart and immediately call wfIsRunning after it might return false as the workflow has yet to start. It might be necessary to loop over some of these functions while waiting for the status to changed.
wfAdd
Adds a new workflow to an existing workflow template.
Code Block | ||
---|---|---|
| ||
def wfAdd(wfName, parameters=None) |
Parameter | Type |
---|---|
wfName | str |
parameters | dict[str, any] |
Info | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Example - wfAdd
or
|
wfDelete
Deletes a workflow.
Code Block | ||
---|---|---|
| ||
def wfDelete(wfName) |
Parameter | Type |
---|---|
wfName | str |
Info | |||||
---|---|---|---|---|---|
Example - wfDelete
|
wfExists
Returns True if the workflow exists.
Code Block | ||
---|---|---|
| ||
def wfExists(wfName) |
Parameter | Type |
---|---|
wfName | str |
Info | |||||
---|---|---|---|---|---|
Example - wfExists
|
wfStart
Starts the workflow. If successful, the workflow has been started but may not yet be running.
Code Block | ||
---|---|---|
| ||
def wfStart(wfName, ec=None) |
Parameter | Type |
---|---|
wfName | str |
ec | str |
Info | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Example - wfStart
or
|
wfSetDebugMode
Sets the workflow debug mode.
Debug mode can be set before starting the workflow or after it has become running.
Code Block | ||
---|---|---|
| ||
def wfSetDebugMode(wfName, on) |
Parameter | Type |
---|---|
wfName | str |
on | bool |
Info | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Example - wfSetDebugMode
or
|
wfIsCompleted
Returns True if the workflow completed.
Code Block | ||
---|---|---|
| ||
def wfIsCompleted(wfName) |
Parameter | Type |
---|---|
wfName | str |
Info | |||||
---|---|---|---|---|---|
Example - wfIsCompleted
|
wfIsRunning
Returns True if the workflow is running.
Code Block | ||
---|---|---|
| ||
def wfIsRunning(wfName) |
Parameter | Type |
---|---|
wfName | str |
Info | |||||
---|---|---|---|---|---|
Example - wfIsRunning
|
wfIsAborted
Returns True if the workflow aborted.
Code Block | ||
---|---|---|
| ||
def wfIsAborted(wfName) |
Parameter | Type |
---|---|
wfName | str |
wfAbortMessage
Returns the workflow abort message, if any.
Code Block | ||
---|---|---|
| ||
def wfAbortMessage(wfName) |
Parameter | Type |
---|---|
wfName | str |
Info | |||||
---|---|---|---|---|---|
Example - wfAbortMessage
|
Event functions
Below is a general example for all event functions.
Our workflow ('Default.test.workflow_1') used in the example below is a simple workflow with a pulse agent connecting to an analysis agent where we debug the input.
For information on how to format the filter see: Event Types(3.0).
Info | |||||
---|---|---|---|---|---|
Example - Event functions
|
eventBufferCreate
Creates an event buffer where events matching filter are stored in memory for later inspection.
Returns the event buffer to be used in calls to other event buffer functions.
Code Block | ||
---|---|---|
| ||
def eventBufferCreate(filter=None, ttl=None, maxSize=None) |
Parameter | Type |
---|---|
filter | dict[str, any] |
ttl | float |
maxSize | int |
eventBufferDestroy
Destroys the event buffer and releases any resources associated with it.
Code Block | ||
---|---|---|
| ||
def eventBufferDestroy(buffer) |
Parameter | Type |
---|---|
buffer | object |
eventBufferSearch
Searches for events in the event buffer matching filter.
Returns an iterator with all currently matching events, with most recent event first.
Code Block | ||
---|---|---|
| ||
def eventBufferSearch(buffer, filter=None) |
Parameter | Type |
---|---|
buffer | object |
filter | dict[str, any] |