8. simulated_auxiliary

8.1. Virtual DUT simulation package

module:

simulated_auxiliary

synopsis:

provide a simple interface to simulate a device under test

This auxiliary can be used as a simulated version of a device under test.

The intention is to set up a pair of CChannels like a pipe, for example a CCUdpServer and a CCUdp bound to the same address. One side of this pipe is then connected to this virtual auxiliary, the other one to a real auxiliary.

The SimulatedAuxiliary will then receive messages from the real auxiliary just like a proper TestApp on a DUT would and answer them according to a predefined playbook.

Each predefined playbooks are linked with real auxiliary received messages, using test case and test suite ids (see simulation). A so called playbook, is a basic list of different Message instances where the content is adapted to the current context under test (simulate a communication lost, a test case run failure…). (see scenario). In order to increase playbook configuration flexibility, predefined and reusable responses are located into response_templates.

pykiso.lib.auxiliaries.simulated_auxiliary.simulated_auxiliary

Simulated Auxiliary

pykiso.lib.auxiliaries.simulated_auxiliary.simulation

Simulation

pykiso.lib.auxiliaries.simulated_auxiliary.scenario

Scenario

pykiso.lib.auxiliaries.simulated_auxiliary.response_templates

ResponseTemplates

8.1.1. Simulated Auxiliary

module:

simulated_auxiliary

synopsis:

auxiliary used to simulate a virtual Device Under Test(DUT)

class pykiso.lib.auxiliaries.simulated_auxiliary.simulated_auxiliary.SimulatedAuxiliary(com=None, **kwargs)[source]

Custom auxiliary use to simulate a virtual DUT.

Initialize attributes.

Parameters:

com – configured channel

8.1.2. Simulation

module:

simulation

synopsis:

map virtual DUT behavior with test case/suite id

Warning

Still under test

class pykiso.lib.auxiliaries.simulated_auxiliary.simulation.Simulation[source]

Simulate a virtual DUT, by playing pre-defined scenario depending on test case and test suite id.

Initialize attributes and mapping.

get_scenario(test_suite_id, test_case_id)[source]

Return the selected scenario mapped with the received test case and test suite id.

Parameters:
  • test_suite_id (int) – current test suite id

  • test_case_id (int) – current test case id

Return type:

Scenario

Returns:

scenario instance containing all steps

handle_default_response()[source]

Return a scenario to handle DUT default behavior.

Return type:

Scenario

Returns:

scenario instance containing all steps

handle_ping_pong()[source]

Return a scenario to handle init ping pong exchange.

Return type:

Scenario

Returns:

scenario instance containing all steps

8.1.3. Scenario

module:

scenario

synopsis:

base object used to create pre-defined virtual DUT scenario.

Warning

Still under test

class pykiso.lib.auxiliaries.simulated_auxiliary.scenario.Scenario(initlist=None)[source]

Container used to create pre-defined virtual DUT scenario.

class pykiso.lib.auxiliaries.simulated_auxiliary.scenario.TestScenario[source]

Encapsulate all possible test’s scenarios.

class VirtualTestCase[source]

Used to gather all virtual DUT test case scenarios based on their fixture level (setup, run, teardown).

class Run[source]

Used to gather all possible scenarios linked to a test case run execution.

classmethod handle_failed_report_run()[source]

Return a scenario to handle a complete test case with failed report at run phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_failed_report_run_with_log()[source]

Return a scenario to handle a complete test case with failed log and report at run phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_run_ack()[source]

Return a scenario to handle a complete test case with lost of communication during ACK to run Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_run_report()[source]

Return a scenario to handle a complete test case with lost of communication during report to run Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_not_implemented_report_run()[source]

Return a scenario to handle a complete test case with not implemented report at run phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_successful_report_run_with_log()[source]

Return a scenario to handle a complete test case with successful log and report at run phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

class Setup[source]

Used to gather all possible scenarios linked to a test case setup execution.

classmethod handle_failed_report_setup()[source]

Return a scenario to handle a complete test case with failed report at setup phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_setup_ack()[source]

Return a scenario to handle a complete test case with lost of communication during ACK to setup Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_setup_report()[source]

Return a scenario to handle a complete test case with lost of communication during report to setup Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_not_implemented_report_setup()[source]

Return a scenario to handle a complete test case with not implemented report at setup phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

class Teardown[source]

Used to gather all possible scenarios linked to a test case teardown execution.

classmethod handle_failed_report_teardown()[source]

Return a scenario to handle a complete test case with failed report at teardown phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_teardown_ack()[source]

Return a scenario to handle a complete test case with lost of communication during ACK to teardown Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_teardown_report()[source]

Return a scenario to handle a complete test case with lost of communication during report to teardown Command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_not_implemented_report_teardown()[source]

Return a scenario to handle a complete test case with not implemented report at teardown phase.

Return type:

Scenario

Returns:

Scenario instance containing all steps

class VirtualTestSuite[source]

Used to gather all virtual DUT test suite scenarios based on their fixture level (setup, teardown).

class Setup[source]

Used to gather all possible scenarios linked to a test suite setup execution.

classmethod handle_failed_report_setup()[source]

Return a scenario to handle a test suite setup with report failed.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_setup_ack()[source]

Return a scenario to handle a lost of communication during ACK to setup command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_setup_report()[source]

Return a scenario to handle a lost of communication during report to setup command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_not_implemented_report_setup()[source]

Return a scenario to handle a test suite setup with report not implemented.

Return type:

Scenario

Returns:

Scenario instance containing all steps

class Teardown[source]

Used to gather all possible scenarios linked to a test suite teardown execution.

classmethod handle_failed_report_teardown()[source]

Return a scenario to handle a test suite teardown with report failed.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_teardown_ack()[source]

Return a scenario to handle a lost of communication during ACK to teardown command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_lost_communication_during_teardown_report()[source]

Return a scenario to handle a lost of communication during report to teardown command.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_not_implemented_report_teardown()[source]

Return a scenario to handle a test suite teardown with report not implemented.

Return type:

Scenario

Returns:

Scenario instance containing all steps

classmethod handle_successful()[source]

Return a scenario to handle a complete successful test case exchange(TEST CASE setup->run->teardown).

Return type:

Scenario

Returns:

Scenario instance containing all steps

8.1.4. ResponseTemplates

module:

response_templates

synopsis:

Used to create a set of predefined messages

Warning

Still under test

class pykiso.lib.auxiliaries.simulated_auxiliary.response_templates.ResponseTemplates[source]

Used to create a set of predefined messages (ACK, NACK, REPORT …).

classmethod ack(msg)[source]

Return an acknowledgment message.

Parameters:

msg (Message) – current received message

Return type:

List[Message]

Returns:

list of Message

classmethod ack_with_logs_and_report_nok(msg)[source]

Return an acknowledge message and log messages and report message with verdict failed + tlv part with failure reason.

Return type:

List[Message]

classmethod ack_with_logs_and_report_ok(msg)[source]

Return an acknowledge message and log messages and report message with verdict pass.

Return type:

List[Message]

classmethod ack_with_report_nok(msg)[source]

Return an acknowledgment message and a report message with verdict failed + tlv part with failure reason.

Parameters:

msg (Message) – current received message

Return type:

List[Message]

Returns:

list of Message

classmethod ack_with_report_not_implemented(msg)[source]

Return an acknowledge message and a report message with verdict test not implemented.

Parameters:

msg (Message) – current received message

Return type:

List[Message]

Returns:

list of Message

classmethod ack_with_report_ok(msg)[source]

Return an acknowledgment message and a report message with verdict pass.

Parameters:

msg (Message) – current received message

Return type:

List[Message]

Returns:

list of Message

classmethod default(msg)[source]

handle default response, if not test case/suite run just return ACK message otherwise ACK + REPORT.

Parameters:

msg (Message) – current received message

Return type:

Message

Returns:

list of Message

classmethod get_random_reason()[source]

Return tlv dictionary containing a random reason from pre-defined reason list.

Parameters:

msg – current received message

Return type:

dict

Returns:

tlv dictionary with failure reason

classmethod nack_with_reason(msg)[source]

Return a NACK message with a tlv part containing the failure reason.

Parameters:

msg (Message) – current received message

Return type:

List[Message]

Returns:

list of Message