Planta_Test API Reference
Information
The package "planta_test" provides additional functionality EXCLUSIVELY for regtests.
No Python functions of this package must ever be called by customizing outside of testing functionality!
Macro Example
This example calls an insert event on a specific record (target)
from planta_test import planta_test
from planta_test import xml_strings
module = ppms.get_focused_module()
cmdstart = '<Cmd type="MenuItemActivation" id="11"><InsertChildWithDAC>'
target = submodule.get_root(0).get_record_by_dac_id("040833", 0).get_children_by_dac_id("044473")[0].get_children_by_dac_id("040270")[2]
cust = submodule.get_customizing().get_dac_by_id('040272')
cmdend = '</InsertChildWithDAC><CurrentDACHasFocus value="true" /></Cmd>'
xml_string = xml_strings.build_client_string(module, start_cmd=cmdstart, active_target=target, customizing=cust, end_cmd=cmdend)
planta_test.call_event(xml_string)
As of S 39.5.17, some variables which cannot be modified through ppms.uvar_set() can be overridden for testing purposes via context handlers provided in ppms.uvar_context.
from ppms.uvar_context import CurrentDateContext, get_current_date
with CurrentDateContext('01.01.2015') as today:
ppms.ui_message_box('override', get_current_date())
do_stuff()
General Functions of planta_test.planta_test
Method | Parameter | Return value | Comment |
|---|---|---|---|
| Tells planta server to write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS | ||
| Tells planta server to not write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS | ||
| Tells planta server to write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS | ||
| Tells planta server to not write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS | ||
| Calls the garbage collection for server objects (e.g. records, dis...). This deletes these objects if the system thinks too many of them are not used anymore | ||
| Forces the garbage collection of any object (e.g. record, di...) the system thinks is not used anymore, regardless of the number of unused objects | ||
| xml_string: String defining an event the Client would send to the Server call_now: optional parameter int/bool: If True (standard value), this event is run immediately. If False, it is queued like any other event, so that it can be found later | True if the event could be handled successfully, False if an Error occured | Executes this simulated event exactly like a real Client event |
| boolean: True on success, False otherwise | Pushes out all data to the client (needed to run serialization during test run) | |
| Resets all profile counters gathered by gcov to zero (Only available when the server was built with gcov support) | ||
| Writes out all the gathered profile information into the build directory (Only available when the server was built with gcov support) | ||
| Raises an assertion that can be catched from python (only for testing the python integration/exception handling) | ||
| boolean | ||
| boolean | ||
| boolean | ||
| int | Returns the configured compression level | |
| enable: boolean, with True enabling compression for following sessions | ||
| level: int, can be a value from 0 (no compression) to 9 (best and slowest compression) | ||
| variable: str, variable ID like '@15': next_value: intended value, type must match variable | Do not use directly, please employ the context handlers like UvarContext or CurrentDateContext (see example above) provided in ppms.uvar_context | |
| variable: str, variable ID like '@15': prev_value: previous value, type must match variable | Do not use directly, please employ the context handlers like UvarContext or CurrentDateContext (see example above) provided in ppms.uvar_context |
General Functions of planta_test
Method | Parameters | Return Value | Comment |
|---|---|---|---|
| module: The Module to execute the event in menu_id: The Menuitem to execute | True if the event was invoked, False if it wasn't | Forging menu items can be used to trigger the execution of overriden menuitems |
Submodule XML_strings.py
This module provides the building of XML strings for Client events.
Method | Parameters | Return Value | Comment |
|---|---|---|---|
| module: The Module of this Event header: String for the XML's header; should usually not be changed start_cmd: string identifying the type of this message. Usually this is the cmd type of an XML string active_target: The object to which this event refers. Can either be a Root, a Record or a data field. If not None, this creates a complete <ActiveTargets> structure under start_cmd active_orderAn order or properties that are sent for the object of parameter active_target, e.g. '<Text>0099</Text>' customizing: The customizing object to which this event refers. Can either be a RootC, a DAC or a DFC. If not None, this sets the complete path to the Customizing object under the <ActiveTargets> (or start_cmd if no active target was set) end_cmd: string terminating the cmd type. Should only be set if the XML event does more than just printing the cmd closing tag closure: final terminater of the XML string. Like the header, this should usually not be changed. | An XML-type string for call_event | The resulting string can be used to simulate a client->server XML message by sending it with call_event |