pyats.aereport.toplevel package

Submodules

aereport – AEReport Top Level Element

This module Contains the class AEReport which is the root node in ResultsDetails.xml report.

class pyats.aereport.toplevel.aereport_top.AEReport

Bases: AEReportElement

Class based on the following schema definition

<xs:schema targetNamespace="http://wwwin-ats.cisco.com/xml/schema/aereport"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="aereport">
    <xs:annotation>
        <xs:documentation>This is xml schema for easypy results report</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="testsuite">
                <xs:complexType>
                    <xs:complexContent>
                        <xs:extension base="TestSuiteType" />
                    </xs:complexContent>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>
generate_dom()

Creates the root element in the DOM tree, and calls generate_dom method on testsuite. It saves the created DOM (for the whole report) in a private member, and returns it.

Returns:

root – The string representation of the created ET

Return type:

DOM tree

get_dom()

Returns the DOM tree

get_dom_as_string()

Returns the DOM tree as xml string

to_xml()

Calls xml method on the child testsuite and returns the xml string

Returns:

xml string for child (testsuite)

Return type:

str

aereportelement – AEReportElement Base Class

This module contains the base class for all schema elements.

class pyats.aereport.toplevel.aereportelement.AEReportElement

Bases: object

AEReportElement is the base class for all schema elements. It implements a default functionality for generating xml. It also defines common attributes and default values.

date_format

The default format for dates across all aereport elements.

Type:

str

tag

Default value = ‘notag’. This is to ensure that all elements contain a tag attribute.

Type:

str

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.

Type:

dict

NO_TAG = 'notag'
NO_VALUE = 'NA'
attrs = None
ctx_name()

Get the ctx_name as a string

date_format = '%Y-%m-%dT%H:%M:%S'
generate_dom(parent)

Creates a DOM element for the current AEReport element. If the current AEReport Element is a class, then it calls generate_dom method on each of its children. If it is a simple type (int, str, bool, etc), then it calls generate_simple_dom to create it.

Parameters:

parent (AEReportElement) – The xml element that should be used as a parent for the current element

generate_simple_elt_dom(parent, child)

Given a simple element (child argument) and a parent, it creates a DOM element for the child and links it to the parent. It converts the child to a str based on its type.

Parameters:
  • parent (AEReportElement) – The parent xml element that should be used for the current element

  • child (int/bool/etc) – simple type

Returns:

dom_elt

Return type:

DOM Element

get_attrs()

Get the attributes of the calling instance

Returns:

attrs attribute of the element. Default is None.

Return type:

dict

get_children()

Gets all attributes (vars) of the calling instance, and returns them as a dictionary. It skips tag and attrs.

Returns:

children – attributes of the calling instance except ‘tag’ and ‘attrs’

Return type:

dict

get_logfile()

Returns the logfile whether it exists directly in the current element or in its initinfo section. If it does not exists, it returns None

Returns:

logfile – Logfile instance if found, else None

Return type:

LogFile

get_logfilepath()

Returns the logfile path whether the logfile exists directly in the current element or in its initinfo section. If no logfile exists, it returns an empty string

Returns:

logfilepath – path to the logfile if it exists, else ‘’

Return type:

str

get_logging_mode()

Return the mode of logging used for this execution

get_parent()

Get the parent

Returns:

parent – parent of element

Return type:

str

get_tag()

Get the tag of the calling instance

Returns:

tag of the element. Default = ‘notag’

Return type:

str

get_unicode_attrs()

Get attribute for for the element

Returns:

attribute

Return type:

str

isstarted()

if certain context is started

isstopped()

Get the attributes of the sttattopptpptp

Returns:

attrs attribute of the element. Default is None.

Return type:

dict

set_parent(parent)

Set the parent

start()

Sets the starttime of the calling element to the current timestamp

start_logfile(filepath)

If instance contains a logfile (directly or in its initinfo), the path for this logfile is set. Also, a snapshot of the file size is recorded in logfile ‘begin’ attributes.

Parameters:

filepath (str) – Path to the log file to be used

stop()

Sets the stoptime of the calling element to the current timestamp. Also calculates the runtime.

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.

tag = 'notag'
to_xml()

Returns a string containing xml for all children of the calling element. xml for each complex child is obtained recursively.

Returns:

xml

Return type:

str

decorators – Decorators

This module contains decorators that implement common functionality that needs to wrap aereport methods.

pyats.aereport.toplevel.decorators.log_it(func)

Log entering and exiting function. It includes, arguments and returning element.

aereportelement – AEReportElement Base Class

This module contains the base class for all schema elements.

class pyats.aereport.toplevel.simplelist.SimpleList(tag, **kwargs)

Bases: AEReportElement

A simple list that contains a tag and value for each item

append(object)

Append object to list

extend(object)

Extend object to list

generate_dom(parent)

Creates a DOM element for the current AEReport element. If the current AEReport Element is a class, then it calls generate_dom method on each of its children. If it is a simple type (int, str, bool, etc), then it calls generate_simple_dom to create it.

Parameters:

parent (AEReportElement) – The xml element that should be used as a parent for the current element