예제 #1
0
 def state_paths(self):
     # type: () -> List[List[EcuState]]
     """
     Returns all state paths. A path is represented by a list of EcuState
     objects.
     :return: A list of paths.
     """
     paths = [
         Graph.dijkstra(self.state_graph, self.__initial_ecu_state, s)
         for s in self.state_graph.nodes if s != self.__initial_ecu_state
     ]
     return sorted([p for p in paths if p is not None] +
                   [[self.__initial_ecu_state]],
                   key=lambda x: x[-1])
예제 #2
0
    def __init__(self, test_cases, **kwargs):
        # type: (Union[List[Union[AutomotiveTestCaseABC, Type[AutomotiveTestCaseABC]]], List[Type[AutomotiveTestCaseABC]]], Any) -> None  # noqa: E501
        self.verbose = kwargs.get("verbose", False)
        self.debug = kwargs.get("debug", False)
        self.unittest = kwargs.pop("unittest", False)
        self.state_graph = Graph()
        self.test_cases = list()  # type: List[AutomotiveTestCaseABC]
        self.stages = list()  # type: List[StagedAutomotiveTestCase]
        self.staged_test_cases = list()  # type: List[AutomotiveTestCaseABC]
        self.test_case_clss = set()  # type: Set[Type[AutomotiveTestCaseABC]]
        self.global_kwargs = kwargs

        for tc in test_cases:
            self.add_test_case(tc)

        log_interactive.debug("The following configuration was created")
        log_interactive.debug(self.__dict__)
예제 #3
0
    def __init__(self, test_cases, **kwargs):
        # type: (Union[List[Union[AutomotiveTestCaseABC, Type[AutomotiveTestCaseABC]]], List[Type[AutomotiveTestCaseABC]]], Any) -> None  # noqa: E501
        self.verbose = kwargs.get("verbose", False)
        self.debug = kwargs.get("debug", False)
        self.delay_state_change = kwargs.get("delay_state_change", 0.5)
        self.state_graph = Graph()

        # test_case can be a mix of classes or instances
        self.test_cases = \
            [e() for e in test_cases if not isinstance(e, AutomotiveTestCaseABC)]  # type: List[AutomotiveTestCaseABC]  # noqa: E501
        self.test_cases += \
            [e for e in test_cases if isinstance(e, AutomotiveTestCaseABC)]

        self.stages = [
            e for e in self.test_cases
            if isinstance(e, StagedAutomotiveTestCase)
        ]

        self.staged_test_cases = \
            [i for sublist in [e.test_cases for e in self.stages]
             for i in sublist]

        self.test_case_clss = set([
            case.__class__
            for case in set(self.staged_test_cases + self.test_cases)
        ])

        for cls in self.test_case_clss:
            kwargs_name = cls.__name__ + "_kwargs"
            self.__setattr__(cls.__name__, kwargs.pop(kwargs_name, dict()))

        for cls in self.test_case_clss:
            val = self.__getattribute__(cls.__name__)
            for kwargs_key, kwargs_val in kwargs.items():
                if kwargs_key not in val.keys():
                    val[kwargs_key] = kwargs_val
            self.__setattr__(cls.__name__, val)

        log_interactive.debug("The following configuration was created")
        log_interactive.debug(self.__dict__)