def test_to_json_without_screenshot(mocker): # mock the response to uuid4() as this will change each time mocker.patch.object(uuid, "uuid4") uuid.uuid4.return_value = "12-ab-34-cd" step_report = StepReport(description="my_description", message="my_message", passed=True) assert step_report.to_json() == { "guid": "12-ab-34-cd", "description": "my_description", "message": "my_message", "passed": True, }
def test_to_json_with_screenshot(mocker): # mock the response to uuid4() as this will change each time mocker.patch.object(uuid, "uuid4") uuid.uuid4.return_value = "56-ef-78-gh" step_report = StepReport( description="another_description", message="another_message", passed=False, screenshot="base64_screenshot_here", ) assert step_report.to_json() == { "guid": "56-ef-78-gh", "description": "another_description", "message": "another_message", "passed": False, "screenshot": "base64_screenshot_here", }
def step(self, description: str, message: str, passed: bool, screenshot: bool = False): """Sends a step report to the Agent Client Args: description (str): The step description message (str): A message that goes with the step passed (bool): True if the step should be marked as passed, False otherwise screenshot (bool): True if a screenshot should be made, False otherwise """ # First update the current test name and report a test if necessary self._command_executor.update_known_test_name() if not self._command_executor.disable_reports: step_report = StepReport( description, message, passed, self._command_executor.create_screenshot() if screenshot else None, ) self._command_executor.agent_client.report_step(step_report) else: logging.debug( f"Step '{description}' {'passed' if passed else 'failed'}")
def step( self, description: str, message: str, passed: bool, screenshot: bool = False, element: ElementSearchCriteria = None, inputs: dict = None, outputs: dict = None ): """Sends a step report to the Agent Client Args: description (str): The step description message (str): A message that goes with the step passed (bool): True if the step should be marked as passed, False otherwise screenshot (bool): True if a screenshot should be made, False otherwise element (ElementSearchCriteria): The step's element search criteria. inputs (dict): Input parameters associated with the step outputs (dict): Output parameters associated with the step """ # First update the current test name and report a test if necessary self._command_executor.update_known_test_name() if not self._command_executor.disable_reports: step_report = StepReport( description, message, passed, self._command_executor.create_screenshot() if screenshot else None, element, inputs, outputs, ) self._command_executor.agent_client.report_step(step_report) else: logging.debug(f"Step '{description}' {'passed' if passed else 'failed'}")
def report_step(self, step_report: StepReport): """Sends step report to the Agent Args: step_report (StepReport): object containing the step to be reported """ endpoint = f"{self._remote_address}{Endpoint.ReportStep.value}" queue_item = QueueItem(report_as_json=step_report.to_json(), url=endpoint, token=self._token) self._queue.put(queue_item, block=False)