Die Dokumentation ab Version 39.5.17 von PLANTA project finden Sie in der neuen PLANTA Online-Hilfe.

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)

NEW 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

From S 39.5.17

Method Parameter Return value Comment
activate_coredumps()     Tells planta server to write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
deactivate_coredumps()     Tells planta server to not write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
activate_heapdumps()     Tells planta server to write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
deactivate_heapdumps()     Tells planta server to not write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
call_garbage_collection()     Calls the garbage collection for server objects (e.g. records, dis...). This deletes these objects if system thinks too many of them are not used anymore
force_garbage_collection()     Forces the garbage collection of any object (e.g. record, di...) the system thinks is not used anymore, no matter how many unused objects there are
call_event(xml_string, call_now = 1) 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
mts_send_pending_data()   boolean: True on success, False otherwise pushes out all data to the client (needed to run serialization during test run)
gcov_reset()     Resets all profile counters gathered by gcov to zero (Only available when the server was built with gcov support)
gcov_dump()     Writes out all the gathered profile information into the build directory (Only available when the server was built with gcov support)
raise_assertion_from_native()     raises an assertion that can be catched from python (only for testing the python integration/exception handling)
get_customizing_permissions()   boolean  
set_customizing_permissions(py_bool) boolean    
compression_is_enabled()   boolean  
compression_get_level()   int returns the configured compression level
compression_set_state(enable) enable: boolean, with True enabling compression for following sessions    
compression_set_level(level) level: int, may be a value from 0 (no compression) to 9 (best and slowest compression)    
uvar_override_set(variable, next_value) NEW 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
uvar_override_clear(variable, prev_value) NEW 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

From S 39.5.2

Method Parameter Return value Comment
activate_coredumps()     Tells planta server to write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
deactivate_coredumps()     Tells planta server to not write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
activate_heapdumps()     Tells planta server to write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
deactivate_heapdumps()     Tells planta server to not write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
call_garbage_collection()     Calls the garbage collection for server objects (e.g. records, dis...). This deletes these objects if system thinks too many of them are not used anymore
force_garbage_collection()     Forces the garbage collection of any object (e.g. record, di...) the system thinks is not used anymore, no matter how many unused objects there are
call_event(xml_string, call_now = 1) 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
mts_send_pending_data()   boolean: True on success, False otherwise pushes out all data to the client (needed to run serialization during test run)
gcov_reset()     Resets all profile counters gathered by gcov to zero (Only available when the server was built with gcov support)
gcov_dump()     Writes out all the gathered profile information into the build directory (Only available when the server was built with gcov support)
raise_assertion_from_native()     raises an assertion that can be catched from python (only for testing the python integration/exception handling)
get_customizing_permissions() NEW   boolean  
set_customizing_permissions(py_bool) NEW boolean    
compression_is_enabled() NEW   boolean  
compression_get_level() NEW   int returns the configured compression level
compression_set_state(enable) NEW enable: boolean, with True enabling compression for following sessions    
compression_set_level(level) NEW level: int, may be a value from 0 (no compression) to 9 (best and slowest compression)    

Up to S 39.5.2

Method Parameter Return value Comment
activate_coredumps()     Tells planta server to write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
deactivate_coredumps()     Tells planta server to not write core dumps if it crashes. Overrides INI-parameter CREATE_CORE_DUMPS
activate_heapdumps()     Tells planta server to write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
deactivate_heapdumps()     Tells planta server to not write heap dumps. Overrides INI-parameter CREATE_HEAP_DUMPS
call_garbage_collection()     Calls the garbage collection for server objects (e.g. records, dis...). This deletes these objects if system thinks too many of them are not used anymore
force_garbage_collection()     Forces the garbage collection of any object (e.g. record, di...) the system thinks is not used anymore, no matter how many unused objects there are
call_event(xml_string, call_now = 1) 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
mts_send_pending_data()   boolean: True on success, False otherwise pushes out all data to the client (needed to run serialization during test run)
gcov_reset() NEW     Resets all profile counters gathered by gcov to zero (Only available when the server was built with gcov support)
gcov_dump() NEW     Writes out all the gathered profile information into the build directory (Only available when the server was built with gcov support)
raise_assertion_from_native()     raises an assertion that can be catched from python (only for testing the python integration/exception handling)

General Functions of planta_test

Method Parameters Return Value Comment
forge_menu_event(module, menu_id) 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
build_client_string(module, header = '<?xml version="1.0" encoding="utf-8"?><Message>', start_cmd = '<Cmd type="DataFieldValue">', active_target = None, active_order = "", customizing = None, end_cmd = '</Cmd>', closure = '</Module></Panel></Message>') 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 to. Can either be a Root, a Record or a Datafield. 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 to. Can either be a RootC, a DAC or a DFC. If not None, this puts 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 print the cmd closing tag

closure: final terminater of the XML string. Like 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

         PLANTA project









 
  • Suche in Topic-Namen

  • Suche in Topic-Inhalten
This site is powered by the TWiki collaboration platform Powered by Perl