DataGen¶
This section contains source code documentation of DataGen extensions.
datagen¶
Extension for data generators
-
class
hydratk.extensions.datagen.datagen.
Extension
(core_instance=None)¶ Class Extension
-
_init_extension
()¶ Method initializes extension
Parameters: none – Returns: void
-
_check_dependencies
()¶ Method checks dependent modules
Parameters: none – Returns: bool
-
_uninstall
()¶ Method returns additional uninstall data
Parameters: none – Returns: list (files), list (modules) Return type: tuple
-
_register_actions
()¶ Method registers actions
Parameters: none – Returns: void
-
_register_htk_actions
()¶ Method registers command hooks
Parameters: none – Returns: void
-
_register_standalone_actions
()¶ Method registers command hooks for standalone mode
Parameters: none – Returns: void
-
gen_asn1
()¶ Method handles command gen-asn1
Encode text file, decode binary file according to ASN.1 specification
Parameters: none – Returns: void
-
gen_json
()¶ Method handles command gen-json
Generate sample JSON file according to JSON specification
Parameters: none – Returns: void
-
gen_xml
()¶ Method handles command gen-xml
Generate sample XML file according to WSDL/XSD specification
Parameters: none – Returns: void
-
gen_selenium
()¶ Method handles command gen-selenium
Adapt Selenium script to Yoda format
Parameters: none – Returns: void
-
bootstrapper¶
Providing custom bootstrapper for datagen standalone app
-
hydratk.extensions.datagen.bootstrapper.
run_app
()¶ Methods runs datagen standalone application
Parameters: none – Returns: void
asn1¶
Module for ASN.1 codec
-
class
hydratk.extensions.datagen.asn1codec.
ASN1Codec
¶ Class ASN1Codec
-
__init__
()¶ Class constructor
Called when object is initialized
Parameters: none – Raises: ValueError
–
-
path
¶ path property getter
-
compile
(spec)¶ Method compiles ASN.1 specification for validation
Parameters: spec (str) – specification filename
Returns: result
Return type: Raises: event
– asn1_before_compileevent
– asn1_after_compile
-
decode
(spec, element, input, iformat='ber', output=None)¶ Method decodes ASN.1 file to readable GSER format
Parameters: Returns: result
Return type: Raises: event
– asn1_before_decodeevent
– asn1_after_decode
-
__weakref__
¶ list of weak references to the object (if defined)
-
encode
(spec, element, input, oformat='ber', output=None)¶ Method encodes ASN.1 file from readable GSER format
Parameters: Returns: result
Return type: Raises: event
– asn1_before_encodeevent
– asn1_after_encode
-
transcode
(spec, element, input, iformat, oformat, output=None)¶ Method transcodes ASN.1 file to different format
Parameters: Returns: result
Return type: Raises: event
– asn1_before_transcodeevent
– asn1_after_transcode
-
jsongen¶
Module for sample JSON generation from JSON schema
-
class
hydratk.extensions.datagen.jsongen.
JSONGen
¶ Class JSONGen
-
__init__
()¶ Class constructor
Called when object is initialized
Parameters: none –
-
path
¶ path property getter
-
schema
¶ schema property getter
-
import_schema
(filename)¶ Method imports schema
Parameters: filename (str) – filename
Returns: result
Return type: Raises: event
– jsongen_before_import_specevent
– jsongen_after_import_spec
-
tojson
(outfile=None)¶ Method creates sample json file
Parameters: outfile (str) – output filename, default sample.json
Returns: result
Return type: Raises: error
– ValueErrorevent
– jsongen_before_writeevent
– jsongen_after_write
-
_tojson_rec
(schema=None)¶ Method creates sample json document
It is used in recursive traversal
Parameters: schema (json) – json schema object Returns: sample json Return type: str Raises: error
– ValueError
-
__weakref__
¶ list of weak references to the object (if defined)
-
xmlgen¶
Module for sample XML generation from WSDL/XSD
-
class
hydratk.extensions.datagen.xmlgen.
XMLGen
¶ Class XMLGen
-
__init__
()¶ Class constructor
Called when object is initialized
Parameters: none –
-
path
¶ path property getter
-
client
¶ client property getter
-
import_spec
(filename)¶ Method imports specification
Parameters: filename (str) – filename
Returns: result
Return type: Raises: event
– xmlgen_before_import_specevent
– xmlgen_after_import_spec
-
toxml
(root, outfile=None, envelope=False)¶ Method creates sample xml file
Parameters: Returns: result
Return type: Raises: event
– xmlgen_before_writeevent
– xmlgen_after_write
-
_toxml_rec
(root, obj=None, ns_cur=None)¶ Method creates sample xml document
It is used in recursive traversal
Parameters: Returns: xml document
Return type: Raises: error
– ValueError
-
_get_element_type
(element)¶ Method gets element XSD type
It is used to determine if element is Simple or Complex
Parameters: element (str) – element name Returns: element type Return type: str Raises: error
– ValueError
-
_get_element_ns
(element)¶ Method gets element XSD namespace
It is used to construct XML element with correct namespaces
Parameters: element (str) – element name Returns: element namespace Return type: str Raises: error
– ValueError
-
__weakref__
¶ list of weak references to the object (if defined)
-
_create_dummy_wsdl
(xsd)¶ Method creates dummy WSDL file
Workaround method: Library suds is designed for SOAP and imports WSDL only Dummy WSDL imports given XSD and is parsed automatically File is stored in same folder as XSD file (with suffix .wsdl)
Parameters: xsd (str) – XSD filename Returns: WSDL filename Return type: str Raises: error
– ValueError
-
serializer¶
Module for class serialization
-
class
hydratk.extensions.datagen.serializer.
Serializer
¶ Class Serializer
-
static
tostr
(obj)¶ Method serializes class instance to string
By default the serializer gets all instance attributes (set in constructor) and writes them in default order. Class can have special class attributes (not set in constructor) _order - list of instance attributes names, it defines serialization order, missing attributes are omitted (not serialized) _naming - dictionary (key - attribute name, value - new name used in serialization)
Parameters: obj (obj) – class instance Returns: str
-
static
toxml
(obj, xml_declaration=False)¶ Method serializes class instance to xml string
Parameters: Returns: str
-
static
tojson
(obj)¶ Method serializes class instance to json string
Method is not supported for Python 2.6
Parameters: obj (obj) – class instance Returns: str Raises: error
– NotImplementedError
-
static
_get_attrs
(obj)¶ Method returns class instance attributes
Parameters: obj (obj) – class instance Returns: dict
-
static
_has_attrs
(obj)¶ Method checks if object has instance attributes
Parameters: obj (obj) – class instance Returns: bool
-
static
_tostr
(obj, level=1)¶ Method serializes given object to string
It is used in recursive traversal Processing per object type (class instance, list, dictionary, simple type)
Parameters: Returns: str
-
static
_toxml
(obj, title=None)¶ Method serializes given object to xml string
It is used in recursive traversal Processing per object type (class instance, list, dictionary, simple type)
Parameters: Returns: str
-
static
_tojson
(obj)¶ Method serializes given object to ordered dictionary
It is used in recursive traversal Processing per object type (class instance, list, dictionary, simple type)
Parameters: obj (obj) – object of any type (not just class instance) Returns: dict
-
__weakref__
¶ list of weak references to the object (if defined)
-
static
selenium¶
Adapter for Selenium scripts to Yoda
-
class
hydratk.extensions.datagen.adapters.selenium.adapter.
Adapter
¶ Class Adapter
-
__init__
()¶ Class constructor
Called when object is initialized
Parameters:
-
suite
¶ suite property getter
-
tests
¶ tests property getter
-
browser
¶ browser property getter
-
timeout
¶ timeout property getter
-
parse_test_suite
(suite, outfile=None)¶ Method parses test suite file
Parameters: Returns: result
Return type: Raises: event
– adapter_before_parse_suiteevent
– adapter_after_parse_suite
-
parse_test
(test)¶ Method parses test file
Parameters: test (str) – test filename
Returns: url (str), steps (list)
Return type: Raises: event
– adapter_before_parse_testevent
– adapter_after_parse_test
-
adapt_suite
(suite, tests)¶ Method adapts suite to scenario
Parameters: Returns: str
-
adapt_test
(idx, test)¶ Method adapts test to case
Parameters: Returns: str
-
adapt_step
(idx, step, url)¶ Method adapts step to condition
Parameters: Returns: str
-
handle_command
(step, url)¶ Method handles command
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_alert
(step, *args)¶ Method handles commands alert
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_close
(step, *args)¶ Method handles command close
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_echo
(step, *args)¶ Method handles command echo
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_go_back
(step, *args)¶ Method handles command goBack
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_open
(step, url, *args)¶ Method handles command open
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_pause
(step, *args)¶ Method handles command pause
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_refresh
(step, *args)¶ Method handles command goBack
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_set
(step, *args)¶ Method handles various commands set
Parameters: Returns: test (str), validate (str)
Return type:
-
__weakref__
¶ list of weak references to the object (if defined)
-
cmd_store
(step, *args)¶ Method handles various commands store
Parameters: Returns: test (str), validate (str)
Return type:
-
cmd_verify
(step, *args)¶ Method handles various commands verify, assert
Parameters: Returns: test (str), validate (str)
Return type:
-