1111import subprocess
1212from typing import Optional , Dict , Any
1313import xml .etree .ElementTree as ET
14- import yaml
1514
1615
1716class TelemetryDataDestination (Enum ):
@@ -36,6 +35,9 @@ class TestStatus(Enum):
3635
3736
3837class Parameters :
38+ """
39+ This class is used to store the parameters for the test case
40+ """
3941
4042 def __init__ (self , category , id , name , value , expected_value , status ):
4143 self .category = category
@@ -45,7 +47,13 @@ def __init__(self, category, id, name, value, expected_value, status):
4547 self .expected_value = expected_value
4648 self .status = status
4749
48- def to_dict (self ):
50+ def to_dict (self ) -> Dict [str , Any ]:
51+ """
52+ This method is used to convert the parameters to a dictionary
53+
54+ :return: Dictionary containing the parameters
55+ :rtype: dict
56+ """
4957 return {
5058 "category" : self .category ,
5159 "id" : self .id ,
@@ -117,9 +125,7 @@ def handle_error(self, exception: Exception, stderr: str = None):
117125 self .result ["message" ] = error_message
118126 self .result ["logs" ].append (error_message )
119127
120- def execute_command_subprocess (
121- self , command : str , shell_command : bool = False
122- ) -> str :
128+ def execute_command_subprocess (self , command : str , shell_command : bool = False ) -> str :
123129 """
124130 Executes a shell command using subprocess with a timeout and logs output or errors.
125131
@@ -130,9 +136,7 @@ def execute_command_subprocess(
130136 :return: Standard output from the command
131137 :rtype: str
132138 """
133- command_string = (
134- command if isinstance (command , str ) else " " .join (command ).replace ("'" , "" )
135- )
139+ command_string = command if isinstance (command , str ) else " " .join (command ).replace ("'" , "" )
136140 self .log (
137141 logging .INFO ,
138142 f"Executing command: { command_string } " ,
@@ -159,7 +163,12 @@ def execute_command_subprocess(
159163
160164 def parse_xml_output (self , xml_output : str ) -> Optional [ET .Element ]:
161165 """
162- Parses the XML output of a command.
166+ Parses the XML output and returns the root element.
167+
168+ :param xml_output: XML output to parse
169+ :type xml_output: str
170+ :return: The root element of the XML output
171+ :rtype: Optional[ET.Element]
163172 """
164173 if xml_output .startswith ("<" ):
165174 return ET .fromstring (xml_output )
0 commit comments