pyats.aereport.testscript package¶
testscript
– TestScript Class¶
This module TestScript Class and related elements.
- class pyats.aereport.testscript.TestScript(logfilepath, logging)¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
- One or more test scripts that are invoked by the job file
Class based on the following schema definition
<xs:element name="testscript" minOccurs="0" maxOccurs="unbounded"> <xs:annotation> <xs:documentation>One or more test scripts that are invoked by the job file</xs:documentation> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:extension base="TestScriptType"> <xs:sequence> <xs:element name="pretestHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="starttime" type="xs:dateTime"></xs:element> <xs:element name="initinfo"></xs:element> <xs:element name="runinfo" type="runinfoType" /> <xs:element name="commonSetup" type="TestSectionType" minOccurs="0"></xs:element> <xs:element name="commonVerify" type="TestSectionType" minOccurs="0"></xs:element> <xs:element name="testcase" type="TestResultType" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="commonCleanup" type="TestSectionType" minOccurs="0"></xs:element> <xs:element name="stoptime" type="xs:dateTime"></xs:element> <xs:element name="runtime"></xs:element> <xs:element name="summary" type="summaryType" /> <xs:element name="posttestHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="cleanonerror" type="cleanType" minOccurs="0"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> <xs:element name="abort" minOccurs="0"></xs:element> </xs:sequence> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element>
- starttime¶
Initalized by aetest::script_init API
- Type
datetime
- initinfo¶
- Type
- commonSetup¶
Optional - This is the section to configure the devices which is common for all the testcases in the script and is enclosed within aetest::common_setup API. All logs go into test script log file
- Type
- commonVerify¶
Optional - This section is for verification invoked via aetest::common_verify API. All logs go into test script log file
- Type
- commonCleanup¶
Optional - This section is invoked via aetest::common_cleanup API and ensures that the steps occuring in common setup and verify are unconfigured here. All logs go into test script log file.
- Type
- commonModify¶
Optional - This section is invoked via aetest::common_modify API
- Type
- stoptime¶
Initalized by aetest::end API?
- Type
datetime
- runtime¶
- Type
timedelta
- abort¶
Optional
- Type
- add_testcase(**kwargs)¶
Create a testcase (TestResult) and append it to the testcases list.
- Parameters
tcid (str) – The id of the testcase to be created. This is set once and never overwritten
variance (str) – Optional - Variance id is the same as TIMS config id. There cannot be a variance id at testcase level if it contains subtests. In such case the variance id will be part of subtest.
name (str) – Name of the testcase/subtest which is equivalent of the Title attribute in TIMS
xref (dict) – xRef
id (dict) – id of the testcase
- add_testsection(**kwargs)¶
Create a testsection (TestSection) and append it to the sections list.
- get_infrahandler(tag, name)¶
Searches within infrahandlers lists whether an infrahandler of a given name already exists. It uses the tag to determine which list to search e.g. pretesthandlers list, etc.
- get_subtest(subtcid)¶
Verify if a subtest exists, if so return it, else return None
- get_testcase(tcid)¶
Verify if a testcase exists, if so return it, else return None
- get_testsection(id)¶
Return the testsection
- is_last_testcase_closed()¶
Return if the last testcase is closed
- Returns
Return 1 if last testcase was closed, else False
- Return type
Bool
- is_last_testsection_closed()¶
Return if the last testsection is closed
- Returns
Return 1 if last testsection was closed, else False
- Return type
Bool
- set_args(**kwargs)¶
Set testscript set_args
- Parameters
Initinfo (#) –
script (dict) – CLI paramerters passed to test script
pargs (str) – CLI paramerters passed to test script
taskid (str) – TaskId is set for easypy runs only; for stand-alone mode, it would be null. This value is internally set by aetest::script_init API
description (str) – Description for the testscript
logfile (dict) – File in which the test script logs are saved
swversion (str) – software version
hwversion (str) – hardware version
tstversion (str) – testscript version
aehandlers (str) – aetest testcase or section handlers
initinfo (dict) – Initinfo
runinfo (dict) – runinfo
Note
Clean is not supported by aetest, hence not supported by aereport. However, the clean API is working, and can be easily enhanced to support clean in testscript. It is working right now for testsuite.
Submodules¶
basetestresult
– BaseTestResult Class¶
This module implements BaseTestResult class. It is the base for testcases and subtests.
- class pyats.aereport.testscript.basetestresult.BaseTestResult¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
XML results for each test result containing setup, test and cleanup sections
Class based on the following schema definition
<xs:sequence> <xs:element name="starttime" type="xs:dateTime" /> <xs:element name="initinfo" type="initInfoType" /> <xs:element name="runinfo" type="runinfoType" /> <xs:element name="setup" type="TestSectionType" minOccurs="0" /> <xs:element name="test" type="TestSectionType" minOccurs="0" /> <xs:element name="section" type="TestSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="cleanup" type="TestSectionType" minOccurs="0" /> <xs:element ref="result"></xs:element> <xs:element name="testresultHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="stoptime" type="xs:dateTime" /> <xs:element name="runtime"></xs:element> <xs:element name="aehandler" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> </xs:sequence>
- starttime¶
starttime
- Type
datetime
- setup¶
setup
- Type
- test¶
test
- Type
- cleanup¶
cleanup
- Type
- result¶
Rollup result is based on individual setup/test, customtest and cleanup sections within the subtest
- Type
- stoptime¶
stoptime
- Type
datetime
- runtime¶
Runtime, stoptime - starttime
- Type
timedelta
- add_testsection(**kwargs)¶
Create a testsection (TestSection) and append it to the sections list.
- get_infrahandler(tag, name)¶
Searches within infrahandlers lists whether an infrahandler of a given name already exists. It uses the tag to determine which list to search (So far there is only one infrahandlers list in basetestresult which is testresulthandlers.
- get_testsection(id)¶
Return the testsection
- is_last_testsection_closed()¶
Return if the last testsection is closed
- Returns
Return 1 if last testsection was closed, else False
- Return type
Bool
- set_args(**kwargs)¶
set basetestresult testscript set_args
- Parameters
name (str) – initinfo/name
description (str) – initinfo/description
pargs (str) – initinfo/pargs
swversion (str) – initinfo/swversion
hwversion (str) – initinfo/hwversion
fwversion (str) – initinfo/fwversion
tstversion (str) – initinfo/tstversion
platform (str) – initinfo/platform
interface (str) – initinfo/interface
id (dict) – id
uut (str) – uut
xref (dict) – xref
logfile (dict) – logfile
diag (str) – Diag for the run
error (str) – Error for the run
userdef (str) – User defined tag
pause (str) – pause
unpause (str) – Unpause
result (str) – Result
scriptname (str) – name of the script
- set_timsextra(**kwargs)¶
Sets tims custom attributes for a testscase or a subtest.
- start_logfile(filepath)¶
Sets the logfile path, and if logging is set to SingleFile, it calculates the size of the logfile at that moment, and uses the value for ‘begin’ attribute of logfile
- Parameters
filepath (str) – Path to the log file to be used
- stop_logfile()¶
If logging is set to SingleFile, it calculates the size of the logfile at that moment, subtracts it from the initial size (value for ‘begin’ attribute) and updates the ‘size’ attribute.
commonsubsection
– CommonSubSection Class¶
This module contains the CommonSubSection class.
- class pyats.aereport.testscript.commonsubsection.CommonSubSection(tag='subSection')¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
Common Subsections are subsections of a TestSection that should only exist in commonsetup and commoncleanup sections
Class based on the following schema definition
<xs:complexType name="CommonSubSectionType"> <xs:sequence> <xs:element name="starttime" type="xs:dateTime"></xs:element> <xs:element name="xref" type="xrefType" /> <xs:element name="id"></xs:element> <xs:element name="name"></xs:element> <xs:element name="description" type="xs:string"></xs:element> <xs:element name="logfile" type="LogFileType"/> <xs:element name="runinfo" type="runinfoType" /> <xs:element ref="result" /> <xs:element name="stoptime" type="xs:dateTime" /> <xs:element name="runtime"></xs:element> </xs:sequence> </xs:complexType>
- starttime¶
testcase start time, internally set by aetst
- Type
datetime
- stoptime¶
- Type
datetime
- runtime¶
- Type
timedelta
- extra¶
that wont be printed in the xml
module
- Type
Dictionary contains extra information
- add_teststep(**kwargs)¶
- get_teststep(tsid)¶
Verify if a step exists, if so return it, else return None
- property module¶
- property path¶
- set_args(**kwargs)¶
set basetestresult testscript set_args
- valid_parents = ['commonSetup', 'commonModify', 'commonVerify', 'commonCleanup']¶
result
– Result¶
This module implement Result section used by TestResult, TestGroup, and TestSection.
- class pyats.aereport.testscript.result.Result¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
Result element for storing test result with values limited to pass, passx, fail, abort, skip, block
Class based on the following schema definition
<xs:element name="result"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="mode"></xs:attribute> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element>
- attrs¶
Default value is None. This is to ensure that all elements contain an attrs dictionary.
attrs
is expanded as attributes in the xml start tag. Indicates how result was determined: Auto = result set by ATS; override = result set by user.- Type
- generate_dom(parent)¶
Override the default behavior of AEReportElement.generate_dom
- Parameters
parent (AEReportElement) – The xml element that should be used as a parent for this userdef
subtestresult
– SubTestResult Class¶
This module implements SubTestResult class
- class pyats.aereport.testscript.subtestresult.SubTestResult(subtcid)¶
Bases:
pyats.aereport.testscript.basetestresult.BaseTestResult
XML results for each test result containing setup, test and cleanup sections
Class based on the following schema definition
<xs:sequence> <xs:element name="starttime" type="xs:dateTime" /> <xs:element name="initinfo" type="initInfoType" /> <xs:element name="runinfo" type="runinfoType" /> <xs:element name="setup" type="TestSectionType" minOccurs="0" /> <xs:element name="test" type="TestSectionType" minOccurs="0" /> <xs:element name="section" type="TestSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="cleanup" type="TestSectionType" minOccurs="0" /> <xs:element ref="result"></xs:element> <xs:element name="testresultHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="stoptime" type="xs:dateTime" /> <xs:element name="runtime"></xs:element> <xs:element name="aehandler" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> </xs:sequence>
- starttime¶
- Type
datetime
- setup¶
setup
- Type
- test¶
test
- Type
- cleanup¶
cleanup
- Type
- result¶
Rollup result is based on individual setup/test, customtest and cleanup sections within the subtest
- Type
- stoptime¶
- Type
datetime
- runtime¶
- Type
timedelta
- children = ['starttime', 'initinfo', 'runinfo', 'setup', 'test', 'sections', 'cleanup', 'result', 'testresulthandlers', 'stoptime', 'runtime', 'aehandlers', 'pause']¶
- property description¶
- property module¶
- property name¶
- property path¶
TestGroup
¶
This module contains the base class for all schema elements.
- class pyats.aereport.testscript.testgroup.TestGroup¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
- XML results for grouping subtests run by test scripts
Class based on the following schema definition
<xs:complexType name="TestGroupType"> <xs:sequence> <xs:element name="starttime" type="xs:dateTime"></xs:element> <xs:element name="id"></xs:element> <xs:element name="initinfo" type="initInfoType"/> <xs:element name="runinfo" type="runinfoType"/> <xs:element name="setup" type="TestSectionType" minOccurs="0"/> <xs:element name="test" type="TestSectionType" minOccurs="0"/> <xs:element name="section" type="TestSectionType" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="subtest" type="TestResultType" maxOccurs="unbounded"/> <xs:element name="cleanup" type="TestSectionType" minOccurs="0"/> <xs:element ref="result"></xs:element> <xs:element name="stoptime" type="xs:dateTime"></xs:element> <xs:element name="runtime"></xs:element> <xs:element name="summary" type="summaryType"/> <xs:element name="aehandler" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> </xs:sequence> </xs:complexType>
- starttime¶
testcase start time, internally set by aetst::testcase begin block
- Type
date
- stoptime¶
testcase end time, internally set up aetest::testcase end block
- Type
date
- testgroupid¶
This is the testgroup id which will typically be not reported in TIMS. But users may choose to report this as separate record in TIMS
- Type
- setup¶
TestSection object
- Type
- test¶
TestSection object
- Type
- sections¶
TestSection object
- Type
- subtests¶
TestResult object
- Type
- cleanup¶
TestSection object
- Type
- result¶
Rollup result is based on individual setup, subtests and cleanup sections within the group tests. But user can also explicitly over-ride it by calling ats_results -result directly.
- Type
- class pyats.aereport.testscript.testgroup.TestGroupId¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
XML results for grouping subtests run by test scripts
Class based on the following schema definition <xs:element name="id"> <xs:annotation>...</xs:annotation> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string">...</xs:element> <xs:element name="tcr" minOccurs="0">...</xs:element> <xs:element name="tims" minOccurs="0">...</xs:element> <xs:element name="testplan" minOccurs="0">...</xs:element> <xs:element name="md5" minOccurs="0">...</xs:element> </xs:sequence> </xs:complexType> </xs:element>
- name¶
This is the testcase id in aetest context specified via -tc_id to aetest::testcase API
- Type
testresult
– TestResult Class¶
This module implements TestResult class
- class pyats.aereport.testscript.testresult.TestResult(tcid, **kwargs)¶
Bases:
pyats.aereport.testscript.basetestresult.BaseTestResult
XML results for each test result containing setup, test and cleanup sections
Class based on the following schema definition
<xs:sequence> <xs:element name="pretestcaseHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="starttime" type="xs:dateTime" /> <xs:element name="initinfo" type="initInfoType" /> <xs:element name="runinfo" type="runinfoType" /> <xs:element name="setup" type="TestSectionType" minOccurs="0" /> <xs:element name="test" type="TestSectionType" minOccurs="0" /> <xs:element name="section" type="TestSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="subtest" type="SubTestResultType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="cleanup" type="TestSectionType" minOccurs="0" /> <xs:element ref="result"></xs:element> <xs:element name="testresultHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="stoptime" type="xs:dateTime" /> <xs:element name="runtime"></xs:element> <xs:element name="posttestcaseHandler" type="InfraHandlerSectionType" minOccurs="0" maxOccurs="unbounded" /> <xs:element name="aehandler" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> </xs:sequence>
- starttime¶
- Type
datetime
- setup¶
setup
- Type
- test¶
test
- Type
- cleanup¶
cleanup
- Type
- result¶
Rollup result is based on individual setup/test, customtest and cleanup sections within the subtest
- Type
- stoptime¶
- Type
datetime
- runtime¶
- Type
timedelta
- add_subtest(**kwargs)¶
Create a testcase (TestResult) and append it to the testcases list.
- Parameters
subtcid (str) – The id of the subtest to be created. This is set once and never overwritten
logfilepath (str) – Path to the log file for the testcase
variance (str) – variance - Variance id is the same as TIMS config id. There cannot be a variance id at testcase level if it contains subtests. In such case the variance id will be part of subtest.
name (str) – Name of the testcase/subtest which is equivalent of the Title attribute in TIMS
xref (dict) – xRef
id (dict) –
- children = ['pretestcasehandlers', 'starttime', 'initinfo', 'runinfo', 'setup', 'test', 'sections', 'subtests', 'cleanup', 'result', 'testresulthandlers', 'stoptime', 'runtime', 'posttestcasehandlers', 'aehandlers', 'pause']¶
- property description¶
- get_infrahandler(tag, name)¶
Searches within infrahandlers lists whether an infrahandler of a given name already exists. It uses the tag to determine which list to search e.g. pretestcasehandlers list, etc.
- get_subtest(id)¶
Return the subtest
- is_last_subtest_closed()¶
Return if the last subtest is closed
- Returns
Return 1 if last subtest was closed, else False
- Return type
Bool
- property module¶
- property name¶
- property path¶
testscriptabort
– TestScriptAbort Class¶
This module implements TestScriptAbort class used by TestScript.
- class pyats.aereport.testscript.testscriptabort.TestScriptAbort(abortfile='')¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
Class based on the following schema definition
<xs:element name="abort" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="time"> <xs:annotation> <xs:documentation>Time when abort signal was received</xs:documentation> </xs:annotation> </xs:element> <xs:element name="abortfile"> <xs:annotation> <xs:documentation>Name of abort file generated to indicate abort condition</xs:documentation> </xs:annotation> </xs:element> </xs:sequence> </xs:complexType> </xs:element>
Examples
>>> abort1 = TestScriptAbort('/path/to/my/file') >>> print abort1.xml() <abort><abortfile>/path/to/my/file</abortfile><time>2014-03-12:23-59-22</time></abort>
- time¶
Time when abort signal was received
- Type
datetime
testsection
– TestSection Class¶
This module implements TestSection class
- class pyats.aereport.testscript.testsection.TestSection(tag='section')¶
Bases:
pyats.aereport.toplevel.aereportelement.AEReportElement
XML results for generic test sections such as testproc, setup, cleanup, common_cleanup, common_setup, etc
Class based on the following schema definition
<xs:sequence> <xs:element name="starttime" type="xs:dateTime" /> <xs:element name="name" minOccurs="0"></xs:element> <xs:element name="xref" type="xrefType" /> <xs:element name="logfile" type="LogFileType" /> <xs:element name="runinfo" type="runinfoType" /> <xs:element name="checkpoint" type="CheckpointType" minOccurs="0" maxOccurs="unbounded" /> <xs:element ref="result" /> <xs:element name="stoptime" type="xs:dateTime"></xs:element> <xs:element name="runtime"></xs:element> <xs:element name="aehandler" minOccurs="0" maxOccurs="unbounded"></xs:element> <xs:element name="pause" minOccurs="0"></xs:element> <xs:element name="subSection" type="CommonSubSectionType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence>
- starttime¶
- Type
datetime
- stoptime¶
section end time, internally set up aetest::section end block
- Type
datetime
- runtime¶
- Type
timedelta
- extra¶
description : Description of the section module name path
- Type
Dictionary contains extra information
- add_commonsubsection(**kwargs)¶
Create a commonsubsection and append it to the commonsubsections list.
- Parameters
logfilepath (str) – Path to the log file for the testcase
variance (str) – variance - Variance id is the same as TIMS config id. There cannot be a variance id at testcase level if it contains subtests. In such case the variance id will be part of subtest.
name (str) – Name of the testcase/subtest which is equivalent of the Title attribute in TIMS
xref (dict) – xRef
id (dict) – id
- add_teststep(**kwargs)¶
- children = ['starttime', 'name', 'description', 'xref', 'logfile', 'runinfo', 'checkpoints', 'result', 'stoptime', 'runtime', 'aehandlers', 'pause', 'commonsubsections', 'teststeps']¶
- common_section_tags = ['commonSetup', 'commonVerify', 'commonCleanup', 'commonModify']¶
- property description¶
- get_commonsubsection(tcid)¶
Verify if a commonsubsection exists, if so return it, else return None
- get_teststep(tsid)¶
Verify if a step exists, if so return it, else return None
- is_last_commonsubsection_closed()¶
Return if the last commonsubsection is closed
- Returns
Return 1 if last commonsubsection was closed, else False
- Return type
Bool
- property module¶
- property path¶
- set_args(**kwargs)¶
- valid_section_tags = ['setup', 'cleanup', 'section', 'commonSetup', 'commonVerify', 'commonCleanup', 'commonModify']¶