reporting.connectors.SYNAPSERT¶
SYNAPSERT.py
SYNAPSERT class
-
class
reporting.connectors.SYNAPSERT.SYNAPSERT(config_file='synapsert_client.json')[source]¶ Bases:
objectClass for TCMS interaction.
-
__init__(config_file='synapsert_client.json')[source]¶ Class initialization.
Parameters: config_file (str) – SYNAPSERT configuration file
-
_check_prefix(issue, prefix, platform)[source]¶ Check if summary of Test Case containts prefix. Return True or prefix is None or prefix exists.
Parameters: Returns: True if platform or prefix in issue
Return type:
-
_create_test_suite(ts_name)[source]¶ Create test suite.
Parameters: ts_name (str) – Jira Test Suite name
-
_do_transition(item, value)[source]¶ Do transition of JIRA issue.
Parameters: - item (JIRA.Issue) – Instance of issue
- value (str) – Name of button
Returns: True in case has been pushed successfully
Return type: Note
Push buttons on issue: Pass, Fail, Cant Test, etc…
-
_generate_servlet(key, issue_type=None)[source]¶ Generate OptionServlet issue or suite to OptionField.
Parameters:
-
_get_all_issues(jql)[source]¶ Get all issue because one request can get only 1,000-2,000 issues.
Parameters: jql (str) – jql request Returns: List of Jira issues Return type: list[JIRA.Issue]
-
_get_all_statuses()[source]¶ Get all available statuses.
Returns: Get all available Jira statuses Return type: list[str]
-
_get_linked_defects(value, auto_tc_name, platform, prefix)[source]¶ Get linked defects.
Parameters: Returns: list of linked defetcs
Return type: list[JIRA.Issue]
Note
Get list of linked defects of SubTests by auto_tc_name, platform and/or prefix.
-
static
_get_suite_value(suite)[source]¶ Get suite value without _test_.
Parameters: suite (str) – Full test suite name Returns: Suite name without _test_ Return type: str
-
_link_issues(test_case, defect_keys)[source]¶ Relink defects to subtest.
Parameters: Returns: True if defect list updated successfully
Return type:
-
_set_allowed_suites(test_case)[source]¶ Set allowed suites.
Parameters: test_case (JIRA.Issue) – Instance of Test Case Note
Get allowed values from ‘Test Suite’ custom field and store them.
-
_set_default_custom_fields()[source]¶ Find and set custom fields.
Note
Serve for operating with custom fields.
-
_set_suite(test_case, suite)[source]¶ Set Test Suite.
Parameters: - test_case (JIRA.Issue) – Jira test case
- suite (str) – Test suite name
-
_update_cf(test_case, custom_field=None, data=None)[source]¶ Update Custom Field.
Parameters: Note
Get customfield_id from allowed values.
-
class_logger= <logging.LoggerAdapter object>¶
-
create_subtest(test_plan, test_case, client=None, build_info=None)[source]¶ Create subtest.
Parameters: Returns: Jira SubTest instance
Return type: JIRA.Issue
-
create_tc(name, description, auto_tc_name, suite=None)[source]¶ Create test case.
Parameters: Returns: instance of Test Case
Return type: JIRA.Issue
-
create_tp(tp_name)[source]¶ Create test plan.
Parameters: tp_name (str) – Summary of Test Plan Returns: Instance of Jira Test Plan Return type: JIRA.Issue
-
get_available_platforms()[source]¶ Get platform field values.
Returns: List with available platforms Return type: list
-
get_cf_value(issue, name)[source]¶ Get custom field value.
Parameters: - issue (JIRA.Issue) – Jira Issue
- name (str) – Name of custom field
Returns: Custom field value
Return type:
-
get_config()[source]¶ Return config fields.
Returns: host, project name, build number, test case state, fail reason, automated test case name, platform Return type: tuple(str)
-
get_custom_fields(issue_type)[source]¶ Get custom fields.
Parameters: issue_type (str) – Jira issue type Returns: Dictionary with custom field name, value pairs Return type: dict{}
-
get_defects_list(tc_key)[source]¶ Get defects of Issue.
Parameters: tc_key (str) – Jira issue key Returns: List of linked defects Return type: list[str]
-
get_issue_by_name(name, issue_type='Test Case')[source]¶ Get Jira issue by name.
Parameters: Returns: JIRA issue
Return type: JIRA.Issue
-
get_issue_key(test_case)[source]¶ Get Issue key.
Parameters: test_case (JIRA.Issue) – Jira issue Returns: Jira issue key Return type: str
-
get_issue_link(tc_key)[source]¶ Get issue links of Test Case.
Parameters: tc_key (str) – Jira issue key Returns: Link to Jira issue Return type: str
-
get_issue_status(issue)[source]¶ Get issue status
Parameters: issue (JIRA.Issue) – Instance of Test Case Returns: Test case status Return type: str
-
get_issue_type_id(issue_type)[source]¶ Get Jira issue type ID.
Parameters: issue_type (str) – Jira issue type Returns: Jira issue type ID Return type: int
-
get_last_failed_issues_from_tps(tp_names, linked_defects)[source]¶ Get last failed issues by test plan name.
Parameters: Raises: Exception – Test Plan does not exist
Returns: List of failed test cases
Return type:
-
get_last_open_tp(tp_name)[source]¶ Return last open Test Plan.
Parameters: tp_name (str) – Jira Test Plan name Returns: Last open Test Plan in JIRA Return type: JIRA.Issue
-
get_last_tp_by_platform(platform)[source]¶ Get latest Test Plan by platform.
Parameters: platform (str) – Platform name Returns: Latest Test Plan by platform Return type: JIRA.Issue
-
get_previous_subtask(auto_tc_name, current_key, platform)[source]¶ Get previous subtask.
Parameters: Returns: Previous Jira issue
Return type: JIRA.Issue
-
get_st_history(auto_tc_name, tp_names)[source]¶ Get history of SubTests.
Parameters: Returns: SubTest history
Return type:
-
static
get_summary(issue)[source]¶ Get summary of Jira issue.
Parameters: issue (JIRA.Issue) – Instance of Test Case Returns: Summary of Jira issue Return type: str
-
get_tc_by_auto_tc_name(auto_tc_name)[source]¶ Get Test Case by auto_tc_name.
Parameters: auto_tc_name (str) – Automated TC Name of Test Case Returns: Instance of Test Case in JIRA Return type: JIRA.Issue
-
get_tc_by_key(tc_key)[source]¶ Get test case by key.
Parameters: tc_key (str) – Jira issue key Returns: Jira Test Case issue Return type: JIRA.Issue
-
get_tracker()[source]¶ Check if tracker exists and sleep on 30 seconds.
Returns: True if connect to Jira host Return type: bool
-
get_transitions(issue)[source]¶ Get available transitions of issue.
Parameters: issue (JIRA.Issue) – Jira issue Returns: List of available transitions Return type: list[str]
-
jira= None¶
-
name= 'SynapseRT'¶
-
set_failure_reason(test_case, value, platform=None, prefix=None)[source]¶ Set Failure Reason.
Parameters:
-
update_tc_status(test_case, status)[source]¶ Update status of test case.
Parameters: - test_case (JIRA.Issue) – Instance of Test Case
- status (str) – Test case status
Raises: ValueError – unknown status
-
reporting.loggers¶
loggers.py
logging functionality for TAF
-
class
reporting.loggers.ClassLogger(log_level='INFO', log_file=None, log_stream=True, for_exception=False, introspection=True)[source]¶ Bases:
objectClass logger descriptor.
-
__get__(instance, owner)[source]¶ This method is called from class.
Note
In case using logger for module level use get() method. __get__() won’t be called from module level.
-
__init__(log_level='INFO', log_file=None, log_stream=True, for_exception=False, introspection=True)[source]¶ Initialize ClassLogger class.
-
-
class
reporting.loggers.LoggerWrapper(logger, level)[source]¶ Bases:
threading.ThreadRead text message from a pipe and redirect them to a logger.
Note
The object itself is able to supply a file descriptor to be used for writing.
fdWrite ==> fdRead ==> pipeReader
-
__init__(logger, level)[source]¶ Setup the object with a logger and a loglevel and start the thread.
-
-
class
reporting.loggers.NoErrArgumentParser(*args, **kwargs)[source]¶ Bases:
argparse.ArgumentParserArgumentParser class that handle only predefined for an instance options.
Note
The original ArgumentParser class raises an error if handle unknown option. But py.test have it’s own options and it’s own custom parser and if ArgumentParser find them it raises an error. Using this class allows not to define all possible options in each module that uses ArgumentParser.
reporting.reporting_server¶
reporting_server.py
Standalone loggingserver for pytest plugin
-
class
reporting.reporting_server.ClientCollector[source]¶ Bases:
objectThread safe object for collecting clients dictionaries.
-
STATUSES= ['Active', 'Inactive']¶
-
active()[source]¶ List of active clients.
Returns: list of clients. Return type: list[dict] Note
There are can be commands from client in queue when client is disconnected (see inprocess() method).
-
addreport(client, report_type)[source]¶ Add and open report type.
Parameters: Raises: KeyError – client not in self.clients
Returns: None
Examples:
client = ("py.test-user-1234", "v.0.0.0.0.0.1") report_type = "html" client_collector.addreport(client, report_type)
-
all()[source]¶ All connected/disconnected client.
Returns: @return: list of clients. Return type: list[dict]
-
class_logger= <logging.LoggerAdapter object>¶
-
closereport(client, report_type)[source]¶ Close report type (set False for existing opened report).
Parameters: Raises: KeyError – client not in self.clients
Returns: None
-
delreport(client, report_type)[source]¶ Remove report type (disabling collecting info for report).
Parameters: Raises: KeyError – client not in self.clients
Returns: None
-
get(client, attr)[source]¶ Return client’s attribute.
Parameters: Returns: Client’s attribute (return type depends on attribute type).
Examples:
client = ("py.test-user-1234", "v.0.0.0.0.0.1") client_collector.get(client, "connect_time") client_collector.get(client, "reports")
-
getall(client)[source]¶ Return all client attributes.
Parameters: client (str) – Tuple of ClientID and build. Returns: client dict. Return type: dict
-
inprocess()[source]¶ List of clients with unprocessed close command.
Returns: list of clients. Return type: list[dict] Note
On close command server should close (and dump) client’s reports.
-
update(client, status)[source]¶ Update status of the client.
Parameters: Raises: ValueError – status not in self.STATUSES
Returns: None
Examples:
client_id = "py.test-user-1234" build = "0.0.0.0.pre-alfa" client_collector.update((client_id, build), ClientCollector.STATUSES[0])
-
-
class
reporting.reporting_server.CommandCollector[source]¶ Bases:
objectThread safe collector for server command queue.
-
add(cmd)[source]¶ Add command to collector.
Parameters: cmd (dict) – Command Returns: Status Return type: bool Examples:
command = {'client': "client-name-with-pid-1111", 'build': 'cool-software-v.0.0.0.1-pre-alfa', 'close': True, 'duration': 15} command_collector.add(command)
-
class_logger= <logging.LoggerAdapter object>¶
-
drop(index)[source]¶ Remove item by index.
Parameters: index (int) – Index of item in queue list. Returns: Command or Error message. Return type: dict|str
-
-
class
reporting.reporting_server.XMLReportingServer(allowNone=False, useDateTime=False)[source]¶ Bases:
twisted.web.xmlrpc.XMLRPCRoot reporting server handler.
Note
This handler receive all test execution information and with command_processor process it to reports.
-
NAME= 'XMLReportingServer'¶
-
check_report_instance(r_type, client_id)[source]¶ Create report instance if any for given client_id and build.
Parameters: Returns: None
-
class_logger= <logging.LoggerAdapter object>¶
-
clients= None¶
-
command_processor(cmd)[source]¶ Processing command from queue.
Parameters: cmd (dict) – Command. Returns: None
-
is_idle()[source]¶ Command processor idle status.
Returns: True if command queue is empty and all clients are in closed state Return type: bool
-
keep_alive_interval= 3600¶
-
keep_alive_last= 1561419714.326169¶
-
last_cmdprocess_status= None¶
-
last_cmdprocess_time= None¶
-
last_operation_time= None¶
-
queue= None¶
-
queue_watchdog()[source]¶ Send commands from queue to command processor in loop.
Raises: Exception – exception while processing command.
-
setup(opts)[source]¶ Create WRTM proxy instance and set necessary attributes.
Parameters: opts (OptionParse) – cli options (OptionParse parsed options). Returns: None
-
watchdog= None¶
-
watchdog_thr= None¶
-
xmlrpc_checklocks()[source]¶ Get CommandCollector and ClientCollector lock statuses.
Returns: CommandCollector and ClientCollector lock statuses. Return type: dict{bool}
-
xmlrpc_clientfullinfo(client)[source]¶ Return full client info.
Parameters: client (tuple(str)) – Tuple of ClientID and build. Returns: Full client dictionary with all attributes. Return type: dict
-
xmlrpc_clientlist(ltype='active')[source]¶ Get list of active clients.
Parameters: ltype (str) – ‘all’|’active’ Returns: list of active clients Return type: list
-
xmlrpc_cmdproccheck()[source]¶ Return queue command processing status.
Returns: Query execution status. Return type: str
-
xmlrpc_cmdprocdisable()[source]¶ Disabling and stopping queue command processing.
Returns: Query execution status. Return type: bool
-
xmlrpc_cmdprocenable()[source]¶ Enabling queue command processing.
Returns: Query execution status. Return type: bool
-
xmlrpc_cmdprocstart()[source]¶ Starting queue command processing.
Returns: Query execution status. Return type: bool
-
xmlrpc_idletime()[source]¶ Return idle time.
Returns: time elapsed from last processed xmlrpc query (int). Return type: int
-
xmlrpc_queuedropcmd(index)[source]¶ Remove command from queue by index.
Parameters: index (int) – Index of command in queue. Returns: Command. Return type: dict Note
It’s recommended to stop queue processing first (see cmdprocdisable method) and check queuelist.
-
xmlrpc_queueidletime()[source]¶ Return queue idle time.
Returns: time elapsed from last processed command (int). Return type: int
-
xmlrpc_queuelastcmdstatus()[source]¶ Get last queue command process status.
Returns: last queue command process status Return type: bool
-
xmlrpc_queuelist()[source]¶ Get command queue list.
Returns: command queue list Return type: list[dict]
-
xmlrpc_reportmethod(report_type, client, method, params=None)[source]¶ Call report class method.
Parameters: Returns: Query execution status if one.
-