API entry point¶
Entry point for the ecu.test Internal API. The Internal API can be used in many expression
controls inside test steps and utilities by using api.
For using it inside function variables and other user code, the Internal API can be instantiated the following way:
from tts.core.api.internalApi.Api import Api
api = Api()
API¶
- class Api¶
Entry point for the Internal API.
- AnalysisEnvironment¶
Object for the
AnalysisEnvironment
- Credentials¶
Access to
Credentialsfor handling Credentials such as certificates and private keys.
- CurrentTestConfiguration¶
Object for the
TestConfiguration
- CurrentTestbenchConfiguration¶
Object for the
TestbenchConfiguration
- DataBrowser¶
Object for the
DataBrowser
- GlobalConstants¶
Object for the
GlobalConstants
- KeywordCatalog¶
Offers key word catalog access methods
- Math¶
Object for
Math
- Multimedia¶
Object for
MultimediaApi
- ObjectApi¶
Use this to access the Object API internally
- TestEnvironment¶
Object for the
TestEnvironment
- TestManagement¶
Object for the
TestManagementApi
- ToolAccess¶
Access to
ToolAccessfor handling job execution.
-
GeneratePackageDocumentation(pkgPath, docPath, doasync=
True)¶ Creates documentation file(s) for a package or all packages in a folder depending on the given path
- Parameters:
- Returns:
Path of the generated (index) document if synchronous mode, otherwise None
- Return type:
str or None
- GetAppName()¶
Returns the application name.
- Return type:
str
- GetSetting(value)¶
Returns a value from the settings file. Possible values are:
configPath
errorLogFile
generatorPath
imagePath
language
logFile
offlineFiuPath
offlineModelPath
offlineSgbdPath
packagePath
parameterPath
reportPath
settingsPath
templatePath
traceFileDir
traceStepPath
userPyModulesPath
utilityPath
workspacePath
- Parameters:
- value : str¶
The setting to return
- Returns:
The current value
- Return type:
str or None
- GetVersion()¶
Returns the ecu.test version.
- Return type:
str
- IsRunner()¶
API classes¶
AnalysisEnvironment¶
- class AnalysisEnvironment¶
Object of analysis job procedure engine.
- ExecutionInfo¶
The current
AnalysisExecutionInfoobject.- Type:
list
- ClearSignalCache()¶
Removes all signals from the signal cache.
Info
Calling this method can be useful in large projects analyzing many object signals (signals that are not of a primitive data type). Object signals are cached in memory. Thus, if the analyses of the project access different object signals, the memory consumption is continuously increasing. Calling this method frees all the memory consumed by the signal cache.
This method should be called at some point in the project, when it is known that most of the previously used signals are not required anymore for the following analyses or if the memory consumption has to be reduced. Calling this method too often, has a negative effect on the execution time.
In order to ensure that the signal cache is cleared completely, this method should be called in a separate episode or the test case part of a package.
AnalysisExecutionInfo¶
- class AnalysisExecutionInfo¶
Provides information for current analysis job execution
- JobResult¶
The result of the current analysis job
Info
During job execution only completed episodes (and child trace steps) are considered. This means, the results of assertions and other steps above an episode are not considered.
- Type:
str
- LogFolder¶
Folder where trace and logging files of the current analysis job are saved during execution
Info
This may be a temporary location, in case a network drive is used.
TargetReportDbFoldermay be used to deduce the final location from the final report location.- Type:
str
- ReportDb¶
Path to report database of current (or most recent) analysis job execution
- Type:
str
- ReportDbFolder¶
Folder of the report database of the current analysis job during execution
Info
This may be a temporary location, in case a network drive is used.
TargetReportDbFolderreturns the final location instead.- Type:
str
- StartTime¶
Time where the current analysis job execution began
- Type:
str
- TargetReportDbFolder¶
Folder of the report database of the current analysis job execution after job completion.
Info
Trace and logging files may be located in the respective subfolders. In case a network drive is used, a temporary location is used during execution that is returned by
ReportDbFolder.- Type:
str
- GetCurrentPackageFilename()¶
Returns the path to the package containing the episode that is currently running
- Returns:
Path to the package
- Return type:
str
- GetMainPackageFilename()¶
Returns the path to the main package
- Returns:
Path to the main package
- Return type:
str
BusSystem¶
- class BusSystem¶
A Bus system
- Channel¶
The channel
- Type:
str
- Database¶
The filename
- Type:
str
- Name¶
The name
- Type:
str
BusSystems¶
- class BusSystems¶
Container for BusSystems. Item Type:
BusSystem- Count¶
The number of items in the collection
- Type:
int
Constant¶
- class Constant¶
A global constant
- Description¶
Returns the description of this constant
- Type:
str
- Name¶
Returns the name of this constant
- Type:
str
- Value¶
Returns the defined value of this constant
- Type:
str
Constants¶
- class Constants¶
Container for Constants. Item Type:
Constant- Count¶
The number of items in the collection
- Type:
int
Ecu¶
- class Ecu¶
An ECU
- A2l¶
The filename of the A2L file
- Type:
str
- DebugHex¶
The filename of the debugger HEX file
- Type:
str
- Elf¶
The filename of the ELF file
- Type:
str
- Elfs¶
The filenames of the ELF files
- Type:
str
- Hex¶
The filename of the HEX file
- Type:
str
- Name¶
The name
- Type:
str
- Sgbd¶
The filename of the SGBD file
- Type:
str
Ecus¶
- class Ecus¶
Container for Ecus. Item Type:
Ecu- Count¶
The number of items in the collection
- Type:
int
EnvironmentCommunication¶
EnvironmentCommunications¶
- class EnvironmentCommunications¶
Container for environment communication systems. Item Type:
EnvironmentCommunication- Count¶
The number of items in the collection
- Type:
int
EnvironmentSimulation¶
- class EnvironmentSimulation¶
An environment simulation system
- Name¶
The name
- Type:
str
- OfflineFile¶
The offline file
- Type:
str
EnvironmentSimulations¶
- class EnvironmentSimulations¶
Container for environment simulation systems. Item Type:
EnvironmentSimulation- Count¶
The number of items in the collection
- Type:
int
GlobalConstants¶
- class GlobalConstants¶
This class represents a container for holding global constants. Use:
GlobalConstants.YourConstantNameto get the value of any self defined constant.
- GetConstants()¶
Returns a list of names containing all constants defined in this container
- Returns:
A list of names
- Return type:
list[str]
-
ORIGIN_DEFINED_AT_RUNTIME =
'defined at runtime'¶
-
ORIGIN_MANIPULATED_AT_RUNTIME =
'manipulated at runtime'¶
KeywordCatalog¶
- class KeywordCatalogApi¶
Internal API for keyword catalog accesses
- Connect()¶
Tries to establish a connection to the keyword catalog server defined in the workspace settings
- Returns:
The connection state: True if the connection has been established, else False
- Return type:
bool
- GetAvailableCatalogs()¶
Returns the available catalogs of the current project
- Returns:
List of available catalog names
- Return type:
list<str>
- GetAvailableProjects()¶
Returns the available projects
- Returns:
List of available project names
- Return type:
list<str>
- GetAvailableVariants()¶
Returns the available variants
- Returns:
List of available variant names
- Return type:
list<str>
- GetCurrentCatalogName()¶
Returns the name of the loaded keyword catalog or None, if no catalog has been loaded
- Returns:
Name of current catalog or None
- Return type:
str or None
- GetCurrentProject()¶
Returns the name of the current project or None, if no project has been configured
- Returns:
Current project name or None
- Return type:
str or None
- GetCurrentVariant()¶
Returns the name of the current variant or None, if no variant has been configured
- Returns:
Current variant name or None
- Return type:
str or None
- IsConnected()¶
Returns the connection state to the keyword catalog server
- Returns:
True, if the connection has already been established, else False
- Return type:
bool
- LoadCatalog(catalogName)¶
Loads the referenced catalog
- Parameters:
- catalogName : str¶
Name of the catalog
- Raises:
exception – If an invalid catalog name has been referenced
- SetProject(projectName)¶
Sets the referenced project
- Parameters:
- projectName : str¶
Project name
- Raises:
exception – If an invalid project name has been referenced
- SetVariant(variantName)¶
Sets the referenced variant
- Parameters:
- variantName : str¶
Variant name
- Raises:
exception – If an invalid variant name has been referenced
Math¶
- class Math
Functions for Math
-
static RandomValue(value, absTolerance, stepSize=
0) Evaluates a random value around a center
- Parameters:
- Returns:
Random value (value - absTolerance <= returnValue <= value + absTolerance)
- Return type:
float
-
static RandomValueMinMax(minValue, maxValue, stepSize=
0, includeMinValue=True, includeMaxValue=False) Evaluates a random value in the from minValue to maxValue. It can be parameterized whether the interval includes minValue (default True) and maxValue (default False).
- Parameters:
- minValue : float¶
Center for the range of possible values
- maxValue : float¶
Tolerance for the used value range (must be >= 0)
- stepSize : float¶
Step size which is used to partition the value range (0 for continous distribution (must be >= 0))
- includeMinValue : bool¶
True if the minValue should be part of the distribution values (closed interval), else False.
- includeMaxValue : bool¶
True if the maxValue should be part of the distribution values (closed interval), else False.
- Returns:
Random value (minValue <= returnValue <= maxValue)
- Return type:
float
-
static RandomValue(value, absTolerance, stepSize=
Model¶
Models¶
- class Models¶
Container for Models. Item Type:
Model- Count¶
The number of items in the collection
- Type:
int
Multimedia¶
Entry point in the internal api for multimedia content
- class ImageFiltersApi¶
Provides access to image filters. Filters are grouped into the two namespaces
defaultanduser. The following filters are provided by ecu.test out of the box:default.BlurFilter(image, Type='GAUSS', Kernelsize=15)default.BWFilter(image, Threshold=-1)default.ColorFilter(image, Colors=["#ff0000"], Tolerance=5)default.ContrastFilter(image, Contrast=1, Brightness=0)default.HSVFilter(image, Hue=0, Saturation=1, Value=1)default.InvertFilter(image)default.RotationFilter(image, Angle=90)
To call a filter you can pass an image object as first argument, followed by any parameter the filter expects. Note that the filter parameters must be passed as keyword arguments. They cannot be passed as positional arguments. If a parameter is omitted it will be filled with its default value. For example to increase the brightness of an image:
>>> filteredImage = api.Multimedia.ImageFilters.default.ContrastFilter(image, Brightness=100)Any user-defined image filter will appear under the namespace
user. Suppose you implemented a custom filter and placed it in the UserPyModules directory. The filter could then be accessed viaapi.Multimedia.ImageFilters.user.MyCustomFilter.Note that all filters will show up in a flat list without accounting for any file system hierarchies. For example a filter located at “UserPyModules/My Image Filters/MyCustomFilter.py” will still show up as
user.MyCustomFilter. Therefore please make sure that your filters use unique module names in order to avoid name clashes.
- class MultimediaApi¶
Provides access to multimedia content at runtime
- ImageFilters¶
Object for
ImageFiltersApi- Type:
list
- GetAvailableOCRServices()¶
Returns a list of available OCR services. These identifiers can be used with GetOCRService.
- Returns:
A list of OCR service identifiers
- Return type:
list<str>
- GetAvailableObjectDetectors()¶
Returns the currently available object detectors.
- Returns:
A list of configured object detectors.
- Return type:
list<str>
- GetAvailableSTTProfiles()¶
Returns the currently available profiles for speech-to-text.
- Returns:
A list of profile dictionaries containing the configured serviceId, profileName, language for each profile.
- Return type:
list<dict<str:str>>
- GetAvailableTTSVoices()¶
Gets the currently available voices for text-to-speech output.
- Returns:
Returns a list of voice dictionaries containing the configured serviceId, voiceName, voiceLanguage, voiceGender for each voice.
- Return type:
list<dict<str:str>>
-
GetDefaultOCRService(sut=
None)¶ Returns the OCR service that is configured in the active test configuration.
- Parameters:
- sut : str | None¶
The system under test whose OCR service should be created. Can be omitted if only one system for media access exists.
- Returns:
A new OCR service instance configured according to the test configuration
- Return type:
- GetOCRService(serviceId)¶
Creates a new OCR service instance from a given sevice ID.
- Parameters:
- serviceId : str¶
Identifier of the OCR service to be created
- Returns:
A new OCR service instance
- Return type:
- GetObjectDetector(detectorId)¶
Creates a new object detector for a given ID.
- Parameters:
- detectorId : str¶
ID of the object detector to be created
- Returns:
A new object detector instance
- Return type:
ObjectDetector
-
SpeechToText(audioBlock, profile=
None)¶ Converts voice to text. Returns the recognized text as a string.
- Parameters:
- audioBlock : AudioBlock¶
The audio recording that should be converted to text.
- profile : dict¶
The profile to be used for speech recognition, identified by a dictionary containing
serviceId,profileName,languageanddescription. SeeGetAvailableSTTProfiles()for a list of valid values. If no profile is provided, the default profile that is configured in the test configuration will be used.
- Returns:
The recognized text
- Return type:
str
-
TextToSpeech(text, voice=
None, parameters=None)¶ Converts text to speech. Returns the spoken text as an AudioBlock.
- Parameters:
- text : str¶
The text that should be converted to speech
- voice : dict¶
The voice to use for speech generation, identified by a dictionary containing
serviceId,voiceName,voiceLanguageandvoiceGender. SeeGetAvailableTTSVoices()for a list of valid values. If no voice is provided, the default voice from the current test configuration will be used.- parameters : dict¶
Optional dictionary with parameters for speech generation. For example the default parameters are
{'pitch': 0, 'speed': 1}
- Returns:
An AudioBlock containing the spoken text
- Return type:
Scm¶
- class Scm¶
Functions for SCM
- GetCheckoutRevision()¶
Returns the revision number of the actual workspace repository
- Returns:
The revision of the actual workspace repository
An empty string if the workspace is not versioned
None if SCM is not available or not enabled in the user settings
- Return type:
str or None
- GetFileRevision(filename)¶
Returns the revision number of a given file
- Parameters:
- filename : str¶
Path to the file. Relative paths will be evaluated as relative to the workspace directory.
- Returns:
The revision of the file, e.g. u”8524” or u”8524m” for a locally modified file
An empty string if the file does not exist or is not versioned
None if SCM is not available or not enabled in the user settings
- Return type:
str or None
- GetFileStatus(filename)¶
Returns the status of a given file
- Parameters:
- filename : str¶
Path to the file. Relative paths will be evaluated as relative to the workspace directory
- Returns:
The SCM status of the file for a locally modified file
An empty string if the file does not exist or is not versioned
None if SCM is not available or not enabled in the user settings
- Return type:
str or None
- GetUrl()¶
Returns the SCM-URL of the workspace directory
- Returns:
The URL of the workspace
None if SCM is not available or not enabled in the user settings
- Return type:
str or None
Service¶
Entry point in the internal api for the Ethernet RBS
- class Service¶
Provides access to simulated Ethernet Services at runtime
-
static GetUsedServices(systemIdentifier=
None, excludeRecordingOnlyMappings=True)¶ Returns all SystemIdentifiers, EcuNames and ServiceNames used in the current test execution
- Parameters:
- Returns:
A set of tuples containing SystemIdentifier, EcuName and ServiceName
- Return type:
set[tuple[str, str, str]]
-
GenerateService(systemIdentifier, ecuName, serviceName, projectName=
'')¶ Generates a service module for
systemIdentifier,ecuNameandserviceName
-
static GetUsedServices(systemIdentifier=
- class ServicePort¶
Functions for Ports in the context of simulated Ethernet Services
- GetService(serviceName)¶
Returns a proxy to the service identified by
serviceName- Parameters:
- serviceName : str¶
Service identifier is a composition of optional projectName and ecuName and serviceName in the format [projectName.]<ecuName>_<serviceName>
- Returns:
Service Proxy
- Return type:
- StartService(serviceName)¶
Starts the service identified by
serviceNameon this port- Parameters:
- serviceName : str¶
Service identifier is a composition of optional projectName and ecuName and serviceName in the format [projectName.]<ecuName>_<serviceName>
- StopService(serviceName)¶
Stops the service identified by
serviceNameon this port- Parameters:
- serviceName : str¶
service identifier is a composition of optional projectName and ecuName and serviceName in the format [projectName.]<ecuName>_<serviceName>
- class ServiceProxy¶
Service proxy for a running simulated Ethernet Service. Service methods can be called on this object, and will be executed on the service instance.
- static GetFunctionsHelp(name, serviceName)¶
Provides the docstring of a function of the service simulation
- static GetServiceFunctions(serviceName)¶
Provides available functions of a service simulation
- Parameters:
- serviceName : str¶
Service identifier is a composition of optional projectName and ecuName and serviceName in the format [projectName.]<ecuName>_<serviceName>
- Return type:
list[str]
TestBench¶
- class TestBench¶
Entry point for starting/stopping tools
- GetPortStatus(portName)¶
Retrieves the status of the port.
- Parameters:
- portName : str¶
Name of the port as shown in the “Host / Tool / Port” column in the test bench configuration editor (e.g. “MDL-DEFAULT01”)
- Returns:
Status of the port
0 (Stopped, shown gray in the tool status monitor)
1 (Started, shown green in the tool status monitor)
2 (Broken, shown red in the tool status monitor)
- Return type:
int
- GetToolStatus(toolId)¶
Retrieves the status of the tool.
- Parameters:
- toolId : str¶
ID of the tool as shown in the tooltip in the test bench configuration editor (e.g. “CONTROLDESKNG01”)
- Returns:
Status of the tool
0 (Stopped, shown gray in the tool status monitor)
1 (Started, shown green in the tool status monitor)
2 (Broken, shown red in the tool status monitor)
- Return type:
int
- StartTool(toolId)¶
Starts the specified tool
Info
This is not the recommended way of changing the status of connected tools. Instead, a configuration change step in a project should be used.
Warning
Updates variable descriptions. Because signals are registered during test case initialization, accessing signals provided by a tool started via this method is in most cases not possible within the same test case.
- Parameters:
- toolId : str¶
ID of the tool as shown in the ToolTip in the testbench configuration editor (e.g. CONTROLDESKNG01)
- Returns:
True if the tool was started successfully or had been started already, else False
- Return type:
bool
- StopTool(toolId)¶
Stops the specified tool.
Info
This is not the recommended way of changing the status of connected tools. Instead, a configuration change step in a project should be used.
Warning
Unloads the model description assigned to the ports of the stopped tool. Can break mapping and timestamp streaming within the same test case.
Any subsequent access to the tool, both explicitly by a test step and implicitly by cleanup for previous test steps, can lead to completely unpredictable behavior after this call.
- Parameters:
- toolId : str¶
ID of the tool as shown in the ToolTip in the testbench configuration editor (e.g. CONTROLDESKNG01)
- Returns:
True if the tool was stopped successfully, had been stopped already or had never been started in the first place, else False
- Return type:
bool
TestbenchConfiguration¶
- class TestbenchConfiguration¶
Object for accessing information about test bench configuration
- Filename¶
The filename of the test bench configuration
- Type:
str
- ToolList¶
List containing objects of type
TestbenchTool- Type:
list(
TestbenchTool)
- GetToolhostInfo()¶
Returns a list of lists containing url, version, revision and loaded patches of all connected toolhosts
- Returns:
List of lists containing toolhost information
- Return type:
list<list>
TestbenchTool¶
- class TestbenchTool¶
Provides information about the respective tool in the test bench configuration
- Jobs¶
List containing the names of the tool jobs
- Type:
list<str>
- Location¶
Location (host) of the tool
- Type:
str
- Name¶
Name of the tool
- Type:
str
- PortList¶
List containing objects of type
ToolPort- Type:
list(
ToolPort)
- Ports¶
Ports of the tool
- Type:
list<str>
- ToolId¶
ID of the tool
- Type:
str
- Version¶
Version of an activated tool (if known)
- Type:
str/None
TestConfiguration¶
- class TestConfiguration¶
Object for accessing information about test configuration
Info
For most properties it is enough to have the test configuration selected and not loaded.
- BusSystems¶
Collection for
BusSystems- Type:
list
- EnvironmentCommunications¶
Collection for
EnvironmentCommunications- Type:
list
- EnvironmentSimulations¶
Collection for
EnvironmentSimulations- Type:
list
- Filename¶
Absolute path of the test configuration
- Type:
str
- NameTester¶
Name of the tester
- Type:
str
- ReloadGlobalMapping()¶
Reloads the global mapping from the test configuration without reloading the whole configuration
Info
Closed files are loaded, changed files are reloaded, additional files are unloaded.
Info
Calling this method has no effect on the package from which it is called but only on subsequent packages.
Warning
Changes in unsaved loaded mapping files are discarded when calling this method!
TestEnvironment¶
- class TestEnvironment¶
Object of test procedure engine
- ExecutionInfo¶
The current
TestExecutionInfoobject
-
GenerateTestReportDocumentFromDB(dbFile, outDir, fmtName=
None, waitUntilFinished=False, fmtConfig=None)¶ Generates a handler-based test report on the filesystem
- Parameters:
- dbFile : str¶
Path to the report database file (.trf or .prf)
- outDir : str¶
The output directory. Absolute or relative to the program’s report directory
- fmtName : str¶
Name of the report format or handler which should be used (optional) (default is HTML)
- waitUntilFinished : boolean¶
Defines whether the API call should block until generation is finished
- fmtConfig : dict<str, str>¶
Optional dictionary {name: value} of additional configuration parameters for the report format
-
GetPackageReferences(filePath, skipDisabled=
True)¶ Gives a set of all referenced sub packages of this package or project depending on the actual configuration
- TimeElapsing()¶
Resumes a stepwise simulation time when entering the context manager. Pauses the simulation time on context manager exit. This requires that a test execution is running. Does have no effect in real time or continuous simulation time.
- Returns:
The context manager.
- Return type:
Iterator[None]
TestExecutionInfo¶
- class ExecutionExceptionInfo¶
Provides information about an exception that has happened during test execution
- GetExceptionTime()¶
Returns the wall clock time when the exception was created.
Note
This value is not synchronized with the time base used in the report of the test step. Due to the logging path, it is inherently captured slightly after the actual exception occurrence.
- Returns:
Unix time in seconds since epoch
- Return type:
float
- GetMessage()¶
Returns the message of the exception
- Returns:
The message of the exception
- Return type:
str
- GetTestStepPortId()¶
Returns the ID (alias) of the port that was used by the test step that caused the exception
- Returns:
The port alias
None, if the test step did not refer to any port
- Return type:
str or None
- GetTestStepToolId()¶
Returns the ID (alias) of the tool that was used by the test step that caused the exception
- Returns:
The tool alias
None, if the test step did not refer to any tool
- Return type:
str or None
- GetTestStepType()¶
Returns the name of the test step type
- Returns:
The name of the test step type
- Return type:
str
- GetType()¶
Returns the name of the exception type
- Returns:
The name of the exception type
- Return type:
str
- class KeywordInfo¶
KeywordInfo provides an interface to query properties of the currently executed keyword teststep
- GetArgumentUnit(argName)¶
Returns the unit of the given argument configured in the test step
- Parameters:
- argName : str¶
The name of the desired argument
- Returns:
Unit of the return parameter
- Return type:
str
- GetArguments()¶
Returns a list of all arguments
- Returns:
All arguments
- Return type:
list<str>
- GetComponentType()¶
Returns the component type
- Returns:
The component type
- Return type:
str
- GetCurrentTimeOptionIteration()¶
Returns the repetition count of the execution implementation
- Returns:
The repetition count
- Return type:
int
- GetId()¶
Returns the keyword ID
- Returns:
The keyword ID or None
- Return type:
int or None
-
GetReturnUnit(retName=
None)¶ Returns the unit of the given return parameter configured in the test step
- Parameters:
- retName : str or None¶
The name of the desired return parameter or None if only one exists
- Returns:
Unit of the return parameter or None
- Return type:
str or None
- GetReturns()¶
Returns a list all return parameters
- Returns:
All return parameters
- Return type:
list<str>
-
GetTimeOptionDuration(asUnit=
None)¶ Returns the minimum duration of the configured time option or None if not set
- Parameters:
- asUnit : str ('ms', 's', 'min', 'h', 'd')¶
Return the value in the desired unit. Default is None, the value as it is.
- Returns:
The minimum duration value
- Return type:
int or float
- GetTimeOptionMode()¶
Returns the mode of the configured time option or None if time option is not set
- Returns:
Mode of the time option
Finally
TrueForWithin
Generally
SyncOnly
- Return type:
str or None
-
GetTimeOptionPollingCycle(asUnit=
None)¶ Returns the polling cycle of the configured time option or None if not set
- Parameters:
- asUnit : str ('ms', 's', 'min', 'h', 'd')¶
Return the value in the desired unit. Default is None, the value as it is.
- Returns:
The polling cycle value
- Return type:
int or float
-
GetTimeOptionTimeout(asUnit=
None)¶ Returns the timeout of the configured time option or None if not set
- Parameters:
- asUnit : str ('ms', 's', 'min', 'h', 'd')¶
Return the value in the desired unit. Default is None, the value as it is.
- Returns:
The timeout value
- Return type:
int or float
- IsControlTestStep()¶
Returns True, if the keyword test step is of type control
- Returns:
True, if the test step is of type control else False
- Return type:
bool
- IsEstablishTestStep()¶
Returns True, if the keyword test step is of type establish
- Returns:
True, if the test step is of type establish else False
- Return type:
bool
- IsStateTestStep()¶
Returns True, if the keyword test step is of type state
- Returns:
True, if the test step is of type state else False
- Return type:
bool
- class TestExecutionInfo¶
Provides information for current test execution.
All API functions refer to the context of the currently synchronously called package. Information within asynchronous/parallel package executions cannot be provided.
- AllProjectsStepCount¶
Total number of project execution steps, including separately executed sub-projects
- Type:
int
- AllProjectsStepsExecuted¶
Number of completed project execution steps, including separately executed sub-projects
- Type:
int
- CurrentLineNumber¶
Line number of the current teststep
- Type:
int
- CurrentTestStepHierarchy¶
Current test step’s hierarchy including all parents’ line numbers (e.g. ‘3/4/17’)
- Type:
str
- KeywordInfo¶
The information object of the current keyword call
- Type:
- LastTestStepResult¶
Test result of the last executed teststep in the same test step hierarchy in main package execution. Not intended for parallel package calls.
- Type:
str
- LogFolder¶
Folder where trace and logging files of the current main package are saved during execution
Info
This may be a temporary location, in case a network drive is used.
TargetReportDbFoldermay be used to deduce the final location from the final report location.- Type:
str
- MainProjectStepCount¶
Total number of project execution steps, excluding separately executed sub-projects
- Type:
int
- MainProjectStepsExecuted¶
Number of completed project execution steps, excluding separately executed sub-projects
- Type:
int
- PackageResult¶
The result of the current package. Not intended for parallel package calls.
- Type:
str
- ProjectResult¶
The result of the current project
- Type:
str
- ProjectStartTime¶
Time where the current project execution began
- Type:
str
- ReportDb¶
Path to report database of current (or most recent) test run
- Type:
str
- ReportDbFolder¶
Folder of the report database of the current test run during execution
Info
This may be a temporary location, in case a network drive is used.
TargetReportDbFolderreturns the final report location instead.- Type:
str
- RunningTime¶
Difference between the current time and the start of the test execution
- Type:
int
- StartTime¶
Time where the current test execution began
- Type:
str
- TargetReportDbFolder¶
Folder of the report database of the current main package after completion of the package run
Info
Trace and logging files may be located in the respective subfolders. In case a network drive is used, a temporary location is used during execution that is returned by
ReportDbFolder.- Type:
str
-
AddArtifact(fileName=
None, filePath='', context=None)¶ Adds an artifact reference to the test report.
- Parameters:
- fileName : str or None¶
File name of the artifact
- filePath : str¶
Path or URI to the artifact. If the file is accessible on the local file system, a md5 hashsum will be calculated. The prefix ‘report://’ denotes a relative path within the current report directory. To copy a file to this location use the
TargetReportDbFolderproperty.- context : str or None¶
Additional context / comment for the artifact.
- AddTestStepReportDetail(text)¶
Adds a text to the “custom data” section of the currently running teststep’s report details
Info
The entry will be added with a leading time stamp of the test execution. This feature is only available within a package execution. When used within a project step (e.g. a project generator) an error will be raised.
- Parameters:
- text : str¶
The text to be added in the report details
- GetCurrentPackageFilename()¶
Returns the file name of the current subpackage
Info
Infos of Packages executed in parallel are not returned.
- Returns:
File name of current subpackage file or an empty string if the Package is not saved
- Return type:
str
- GetCurrentPackagePath()¶
Returns the absolute file system path of the current subpackage
Info
Infos of Packages executed in parallel are not returned.
- Returns:
Absolute path of current subpackage file
An empty string if the Package is not saved
- Return type:
str
- GetCurrentProjectFilename()¶
Returns the file name of the current project
- Returns:
File name of current project
An empty string, if the project has not been saved yet
None, if no project is running
- Return type:
str or None
- GetCurrentProjectPath()¶
Returns the absolute file system path of the current project
- Returns:
Absolute path of the current project
An empty string, if the project has not been saved yet
None, if no project is running
- Return type:
str or None
- GetExecutionExceptionInfo()¶
Returns a list of exceptions that have occured during the execution of this package. This information is also available in error recovery packages.
- Returns:
A list of exception info objects
- Return type:
list<
ExecutionExceptionInfo>
- GetExecutionMode()¶
Returns the bit field coding the execution mode of the package or project:
NO_JOB_EXECUTION = 0
SEQUENTIAL_JOB_EXECUTION = 1
PARALLEL_JOB_EXECUTION = 2 (project execution only)
DISABLE_JOBREPORT_MERGE = 4 (project execution only)
SKIP_TESTCASE = 8
DOWNSTREAM_JOB_EXECUTION = 16 (project execution only)
- Returns:
bit field coding the execution mode of the package or project.
- Return type:
int
Info
May return None if called within the trace analysis during PARALLEL_JOB_EXECUTION. SEQUENTIAL_JOB_EXECUTION, PARALLEL_JOB_EXECUTION and DOWNSTREAM_JOB_EXECUTION can not be set at the same time.
- GetKeywordInfo()¶
Returns an information object of the current executed keyword call
- Returns:
The information object of the current keyword call
- Return type:
- GetMainPackageFilename()¶
Returns the file name of the running main package
- Returns:
File name of current main package file
An empty string if the package is not saved
- Return type:
str
- GetMainPackagePath()¶
Returns the absolute file system path of the running main package
- Returns:
Absolute path of current main package file
An empty string if package is not saved
- Return type:
str
-
GetMappingNames(scope=
'exec')¶ Returns a list of all available mappings for the chosen scope of the current package.
Info
This function is not supported in parallel packages.
- Parameters:
- scope : str¶
The scope of the mapping space to look in. Possible values are
exec: The execution mapping space of the current package.
project: The project mapping space, i.e., mappings defined in parameter sets or project folders.
global: The global mapping space, i.e., mappings defined via a test configuration or a currently loaded .xam file.
all: All combined mapping spaces.
- Returns:
Mapping names of the chosen scope.
- Return type:
list[str]
- Raise:
TTError if the scope is ‘project’ but there is no project running.
-
GetMappingTargetPath(mappingName, scope=
'exec')¶ Returns the target path of the mapping with the given name depending on the chosen scope.
Info
This function is not supported in parallel packages.
- Parameters:
- mappingName : str¶
Name of the mapping.
- scope : str¶
The scope of the mapping space to look in. Possible values are
exec: The execution mapping space of the current package.
project: The project mapping space, i.e., mappings defined in parameter sets or project folders.
global: The global mapping space, i.e., mappings defined via a test configuration or a currently loaded .xam file.
all: All combined mapping spaces. Returns always the target path of that mapping that has the highest priority throughout all scopes.
- Returns:
The target path for the given mapping name of the chosen scope.
None if it is a generic mapping.
- Raise:
TTError if
the scope is ‘project’ but there is no project running.
there is no mapping of the given name in the scope.
- Return type:
str | None
-
GetWatchTime(key=
'DefaultWatch')¶ Returns the difference between the current time and the start of a watch
- Returns:
The time difference [ms]
- Return type:
int
- IsAbortRequested()¶
Returns True if the user has requested an abort.
Info
This method should be used to check if an abort is requested in long-running implementations (e.g. in UserPyModules, generators, package inline code or utility implementations) in order to abort this routine. Returns False if the abort of an execution has already been completed.
- Returns:
True if the user has requested an abort else False.
- Return type:
bool
- IsAborted()¶
Returns True if a package or project is aborted.
- Returns:
True if abort is sent by a package or project.
- Return type:
bool
- IsInMain()¶
Checks if execution is currently neither in a pre- nor a postcondition block
- Returns:
True, if the currently executed test step is not in a pre- or postcondition block else False
- Return type:
bool
- IsInPostcondition()¶
Checks if execution is currently in postcondition block
- Returns:
True, if a postcondition block is currently executed else False
- Return type:
bool
- IsInPrecondition()¶
Checks if execution is currently in precondition block
- Returns:
True, if a precondition block is currently executed else False
- Return type:
bool
- IsInteractiveExecution()¶
Checks if test is executed interactively
- Returns:
True, if test is executed interactively
False, if test is not executed interactively
None, if no execution is running
- Return type:
bool or None
TestManagement¶
- class TestManagementApi¶
API to interact with the configured test management system.
Info
Test management must be configured and already successfully authenticated.
- GetTestScriptByID(testScriptId)¶
Queries a test script by its ID. The returned data object corresponds to the interface of almhooks.
- Parameters:
- testScriptId : str¶
String value of the identifer, e.g.: “42” or “TT-1234”
- Returns:
Data object of the Almhook Interface representing a test script.
- Raises:
exception – if a user adapter is currently active. Or the test management system is not configured. Or the user is not authenticated.
- Return type:
TestScript
ToolAccess¶
- class JobExecutor¶
Object for executing jobs on tools or ports.
- class ToolAccess¶
Entry point for executing jobs on tools or ports.
Workspace¶
- class Finding¶
Represents a finding returned by method
Workspace.Check().- Variables:
- message
a message describing the finding
- severity
a severity (note, warning, error, exception)
- filepath
optionally, a file path if the finding occurred in an artifact
- lineno
optionally, a line number in the artifact where the finding occurred
- stepId
optionally, a step ID to identify the exact source of the finding
- id
optionally, an ID to identify the finding
- origin
optionally, the workspace namespace of the checker. None if its the main workspace.
- fixed
the fix state of the finding
- class Workspace¶
Access to workspace related information.
-
Check(item, recursive=
None, fix=False)¶ Checks an item and returns a list of findings.
- Parameters:
- item : str | Path¶
The item to check. Supported are file paths to packages and analysis packages. The paths have to be absolute or relative to the “packages” directory.
- recursive : bool | None¶
If True, referenced items (that are supported) are also checked. If False, only the item itself is checked. If None, the default behavior as set in the workspace settings is used.
- fix : bool¶
If True, the check will attempt to fix findings that have a fix available.
- Returns:
a list of findings
- Return type:
list[Finding]
-
Check(item, recursive=
Credentials API¶
Introduction¶
The credentials API can be used to manage and access credentials such as certificates and private keys.
Keystores¶
Certificates and private keys are stored in keystores, e.g. PKCS12 files. These keystores are meant to prevent direct access to especially private keys. For example, PKCS12 files can be encrypted by a password to protect the private key from simple plaintext access via the file system.
Managing Keystores¶
Keystores can be created or loaded in the central vault of ecu.test to access them later within a test case, e.g. via path and the password of a PKCS12 file via CreatePkcs12KeyStore and LoadPkcs12KeyStore. The vault is encrypted and secured by a central password that must be provided by the user to decrypt and gain access to the saved keystores - similar to the concept of a password manager.
Accessing Keystores¶
Previously created or loaded keystores can be simply accessed as attribute or by GetVaultEntry:
>>> api.Credentials.OpenCryptFileVault(...)
>>> api.Credentials.CreatePkcs12KeyStore("myKeyStore", ...)
>>> ...
>>> api.Credentials.myKeyStore.GetPrivateKey()
>>> api.Credentials.GetVaultEntry("myKeyStore").GetCertificates()
Secrets¶
Simple secrets such as strings or byte streams can be stored directly in the vault. Analogously to keystores, they can be accessed as attribute or by GetVaultEntry:
>>> api.Credentials.OpenCryptFileVault(...)
>>> api.Credentials.CreateSecret("secret", "e25f790f00e553b82592626a2a948a64", "accessToken")
>>> ...
>>> api.Credentials.secret.Reveal()
'e25f790f00e553b82592626a2a948a64'
>>> api.Credentials.GetVaultEntry("secret").AssociatedData()
'accessToken'
Managing the Vault¶
Currently, the central vault is a password encrypted file containing the access data to the different keystores. One can simply create a vault by CreateCryptFileVault or load an existing one by OpenCryptFileVault.
Security¶
See security notes for the vault in the workspace settings documentation.
Warning
Providing the password directly via API can currently reveal the central password by reporting. To circumvent reporting, it is advised to use the credentials API within function variables or UserPyModules.
Examples¶
Creating a vault:
>>> api.Credentials.CreateCryptFileVault("C:/<path>/vault")
>>> api.Credentials.Close()
Creating a PKCS12 keystore:
>>> api.Credentials.OpenCryptFileVault("C:/<path>/vault")
>>> pkcs = "C:/<path>/service29.pkcs"
>>> privateKey = "C:/<path>/private.key"
>>> certs = ["C:/<path>/Service29.crt"]
>>> api.Credentials.CreatePkcs12KeyStore("service29", pkcs, privateKey, certs)
>>> api.Credentials.Save()
>>> api.Credentials.Close()
Accessing keystores:
>>> # Assuming the vault has been opened beforehand
>>> privateKey = api.Credentials.service29.GetPrivateKey()
>>> cert = api.Credentials.service29.GetCertificate("SERVICE-29") # common name SERVICE-29
>>> signature = privateKey.Sign(ByteStream(b"message"))
>>> cert.Verify(signature, ByteStream(b"message"))
True
>>> cert.Verify(signature, ByteStream(b"nonsense"))
False
Credentials¶
- class Credentials¶
Access to the Credentials API
- Certificate¶
Returns Certificate API for utility methods.
- Return type:
- Close()¶
Closes the vault. Unsaved modifications will be discarded!
- CreateCryptFileVault(path, vaultPassword)¶
Creates a new crypt file vault. After that the new vault will be open.
-
CreatePkcs12KeyStore(identifier, filePath, privateKey=
None, certs=None, password='')¶ Creates the PKCS12 file with its given path, private key, certificates and password. The created PKC12 file is stored afterward.
- Parameters:
- identifier : str¶
This identifier will be used to reference the created keystore. The identifier has to be a valid python variable name without leading underscores.
- filePath : str¶
The path of the PKCS12 file to be created.
- privateKey : str | None¶
Path to the private key that will be stored in the PKCS12 file. If not given, the PKCS12 file will be created without a private key.
- certs : list[str] | None¶
Certificates that will be stored in the PKCS12 file. The certificates can be given as files paths or standard base64 encoded strings. Additionally, they have to be ordered as certificate chain. If not given, the PKCS12 file will be created without certificates.
- password : str¶
Password for accessing the PKCS12 file. If the PKCS12 file shall not be password protected, just choose an empty password.
- Return type:
-
CreateSecret(identifier, secret, associatedData=
None)¶ Creates and saves the secret with its associated data.
- Parameters:
- identifier : str¶
This identifier will be used to reference the created keystore. The identifier has to be a valid python variable name without leading underscores.
- secret : str¶
The secret to be stored, e.g. passwords, tokens.
- associatedData : Any¶
Additional data associated with the secret. Data has to be JSON serializable.
- Return type:
- DeleteVaultEntry(identifier)¶
Deletes the vault entry with the given identifier.
- GetAvailableVaultEntries()¶
Returns all available vault entry identifiers.
- Return type:
list[str]
- GetTesterKey(vaultPassword)¶
Returns the tester key.
- Parameters:
- vaultPassword : str¶
The password of the vault.
- GetVaultEntry(identifier)¶
Returns the vault entry with the given identifier.
-
LoadPkcs12KeyStore(identifier, filePath, password=
'')¶ Loads and stores an existing PKCS12 file given by its path and password.
- Parameters:
- identifier : str¶
This identifier will be used to reference the created keystore. The identifier has to be a valid python variable name without leading underscores.
- filePath : str¶
The path of the PKCS12 file.
- password : str¶
Password for accessing the PKCS12 file. If the PKCS12 file is not password protected, just choose an empty password.
- Return type:
- OpenCryptFileVault(path, vaultPassword)¶
Opens the crypt file vault. The vault can only be modified if it has been opened.
Access via password allocates for a short time ca. 2 GB RAM.
- OpenVault(vaultPassword)¶
Opens the vault that is configured in credential settings. The vault can only be modified if it has been opened.
Access via password allocates for a short time ca. 2 GB RAM.
- Parameters:
- vaultPassword : str¶
The password or tester key of the vault.
- PrivateKey¶
Returns PrivateKey API for utility methods.
- Return type:
- Save()¶
Saves all modifications.
- SeedAndKey¶
Returns SeedAndKey API for generating keys from seeds.
- Return type:
KeyStore¶
- class KeyStore¶
Keystore for saving credentials.
- Delete()¶
Deletes the vault entry.
- GetCertificate(name)¶
Returns the certificate with the given name. For PKCS12 files the common name of the certificate is used as identifier.
- Parameters:
- name : str¶
The name of the certificate that will be used to identify it.
- Return type:
- GetCertificateChain(name)¶
Returns the certificate chain for the certificate with the given name. For PKCS12 files the common name of the certificate is used as identifier.
- Parameters:
- name : str¶
The name of the certificate that will be used to identify it.
- Return type:
list[
Certificate]
- GetCertificates()¶
Returns all stored certificates.
- Return type:
list[
Certificate]
- GetPrivateKey()¶
Returns the private key.
- Return type:
PrivateKey| None
Secret¶
- class Secret¶
- AssociatedData()¶
Additional data associated with the secret.
- Delete()¶
Deletes the vault entry.
- Reveal()¶
Returns the stored secret.
- Return type:
str
Certificate¶
- class Certificate¶
- Base64()¶
Returns the certificate as base64 encoded string.
- Return type:
str
- CommonName()¶
Return the common name of this certificate.
- Return type:
str
- DER()¶
Return the certificate as bytes in DER format.
- Return type:
- classmethod FromBase64(data)¶
Create a Certificate instance from base64 encoded data.
- Parameters:
- data : str¶
Base64 encoded data
- Return type:
- classmethod FromDER(data)¶
Create a Certificate instance from DER encoded data.
- Parameters:
- data : ByteStream¶
DER encoded data
- Return type:
- classmethod FromFile(filePath)¶
Creates a Certificate instance from a PEM or DER formatted file.
- Parameters:
- filePath : str¶
Path of certificate file.
- Return type:
- classmethod FromPEM(data)¶
Create a Certificate instance from PEM encoded data.
- Parameters:
- data : str¶
PEM encoded data
- Return type:
-
IsValid(hours=
0)¶ Checks if the certificate is still valid for at least the given amount of time.
- Parameters:
- hours : int¶
The minimum number of hours for which the certificate must still be valid.
- Return type:
bool
- Issuer()¶
Return the issuer of this certificate.
- Return type:
str
- PEM()¶
Returns the certificate as PEM encoded string.
- Return type:
str
- Subject()¶
Return subject of this certificate.
- Return type:
str
- Verify(signature, message)¶
Verifies a signature of the given message.
- Parameters:
- signature : ByteStream¶
The supposed signature of the message created by the corresponding private key.
- message : ByteStream¶
The message that has been signed.
- Returns:
True, if the verification is successful, otherwise False.
- Return type:
bool
PrivateKey¶
- class PrivateKey¶
- classmethod FromBase64(data)¶
Create a PrivateKey instance from base64 encoded data.
- Parameters:
- data : str¶
Base64 encoded data
- Return type:
- classmethod FromDER(data)¶
Create a PrivateKey instance from DER encoded data.
- Parameters:
- data : ByteStream¶
DER encoded data
- Return type:
- classmethod FromFile(filePath)¶
Creates a PrivateKey instance from a PEM or DER formatted file.
- Parameters:
- filePath : str¶
Path of private key file.
- Return type:
- classmethod FromPEM(data)¶
Create a PrivateKey instance from PEM encoded data.
- Parameters:
- data : str¶
PEM encoded data
- Return type:
PublicKey¶
- class PublicKey¶
- Base64()¶
Returns the public key as base64 encoded string.
- Return type:
str
- DER()¶
Return the public key as bytes in DER format.
- Return type:
- classmethod FromDER(data)¶
Create a PublicKey instance from DER encoded data.
- Parameters:
- data : ByteStream¶
DER encoded data
- Return type:
- PEM()¶
Returns the public key as PEM encoded string.
- Return type:
str
- Verify(signature, message)¶
Verifies a signature of the given message.
- Parameters:
- signature : ByteStream¶
The supposed signature of the message created by the corresponding private key.
- message : ByteStream¶
The message that has been signed.
- Returns:
True, if the verification is successful, otherwise False.
- Return type:
bool
SeedAndKey¶
- class SeedAndKey¶
- Diag¶
Diagnostics related seed and key API
alias of
DiagSeedAndKey
- Xcp¶
XCP related seed and key API
alias of
XcpSeedAndKey
DiagSeedAndKey¶
- class DiagSeedAndKey¶
- classmethod FromLib(libPath)¶
Returns DiagSeedAndKey instance for accessing libPath seed and key API.
- Parameters:
- libPath : str¶
The path of the dll. This path can be relative to the workspace or absolute.
- Return type:
- GenerateKeyEx(seed, securityLevel, ecuVariant)¶
Generates the key from the seed by using the previously passed library. Internally the user defined function GenerateKeyEx() is called.
- Parameters:
- Return type:
- GenerateKeyExOpt(seed, securityLevel, ecuVariant, options)¶
Generates the key from the seed by using the previously passed library. Internally the user defined function GenerateKeyExOpt() is called.
- Parameters:
- Return type:
XcpSeedAndKey¶
- class XcpSeedAndKey¶
- ComputeKeyFromSeed(seed, privilege)¶
Compute key from seed by using the previously passed library.
- Parameters:
- Return type:
- classmethod FromLib(libPath)¶
Returns XcpSeedAndKey instance for accessing libPath seed and key API.
- Parameters:
- libPath : str¶
The path of the dll. This path can be relative to the workspace or absolute.
- Return type:
- GetAvailablePrivileges()¶
Get privileges given by the seed and key dll.
- Return type:
int