Exemplo n.º 1
0
 def test_default(self):
     lines = ['aapeli', 'beeveli', 'oopeli', 'huhheli', 'strange bird']
     self.assertTrue(verify_message(lines, ['oopeli', 'huhheli']))
     self.assertFalse(verify_message(lines, ['oopeli', 'huhhelis']))
     self.assertFalse(verify_message(lines, ['oopeli', 'huhhe li']))
     self.assertFalse(verify_message(lines, [False]))
     self.assertTrue(verify_message(lines, ['strange bird']))
Exemplo n.º 2
0
    def verify_trace(self, k, expected_traces, break_in_fail=True):
        """
        Verify that traces expected_traces are found in dut traces.

        :param k: index or nick of dut whose traces are to be used.
        :param expected_traces: list of expected traces or string
        :param break_in_fail: Boolean, if True raise LookupError if search fails
        :return: boolean.
        :raises: LookupError if search fails.
        """
        if isinstance(k, str):
            dut_index = self._resources.get_dut_index(k)
            return self.verify_trace(dut_index, expected_traces, break_in_fail)

        # If expectedTraces given as a String (expecting only a certain trace), wrap it in a list.
        if isinstance(expected_traces, str):
            expected_traces = [expected_traces]

        status = True
        try:
            status = verify_message(self._resources.duts[k - 1].traces,
                                    expected_traces)
        except TypeError as inst:
            status = False
            if break_in_fail:
                raise inst
        if status is False and break_in_fail:
            raise LookupError(
                "{} not found in traces.".format(expected_traces))
        return status
Exemplo n.º 3
0
    def case(self):
        # get dut
        dut = self.get_dut(1)

        # print dut information
        dut.print_info()

        # get dut serial port
        self.logger.info("DUT serial port is %s" % dut.comport)

        # write data to dut
        dut.writeline(data="echo 'This is a testing line write to dut'")

        # wait 1 second
        self.delay(1)

        # verify message from trace
        verify_message(dut.traces, 'This is a testing line write to dut')
Exemplo n.º 4
0
    def verify_trace(self, expected_traces, break_in_fail=True):
        """
        Verifies that expectedResponse is found in self.traces

        :param expected_traces: response or responses to look for. Must be list or str.
        :param break_in_fail: If set to True, re-raises exceptions caught or if message was
        not found
        :return: True or False
        :raises: LookupError if message was not found and breakInFail was True. Other Exceptions
        might also be raised through searcher.verify_message.
        """
        ok = True
        try:
            ok = verify_message(self.traces, expected_traces)
        except (TypeError, LookupError) as inst:
            ok = False
            if break_in_fail:
                raise inst
        if ok is False and break_in_fail:
            raise LookupError("Unexpected message found")
        return ok
Exemplo n.º 5
0
 def test_false_type(self):
     with self.assertRaises(TypeError):
         verify_message([], 1)
Exemplo n.º 6
0
 def test_set(self):
     lines = ['aapeli', 'beeveli', 'oopeli', 'huhheli']
     self.assertTrue(verify_message(lines, {"aapeli"}))
     self.assertTrue(verify_message(lines, {"oop"}))
     self.assertFalse(verify_message(lines, {"ai"}))
     self.assertFalse(verify_message(lines, {1}))
Exemplo n.º 7
0
 def test_string(self):
     lines = ['aapeli', 'beeveli', 'oopeli', 'huhheli']
     self.assertTrue(verify_message(lines, "aapeli"))
     self.assertTrue(verify_message(lines, "oop"))
     self.assertFalse(verify_message(lines, "ai"))
Exemplo n.º 8
0
 def test_regex(self):
     lines = ['aapeli', 'beeveli', 'oopeli', 'huhheli']
     self.assertTrue(verify_message(lines, ['^aa', '^be', '^oopeli']))
     self.assertFalse(verify_message(lines, ['^aa', '^opeli']))
Exemplo n.º 9
0
 def test_invert(self):
     lines = ['aapeli', 'beeveli', 'oopeli', 'huhheli']
     self.assertTrue(verify_message(lines, ['oopeli', Invert('uups')]))
     self.assertFalse(verify_message(lines, ['oopeli', Invert('huhheli')]))
     self.assertFalse(verify_message(lines, ['oopeli', Invert('huhheli')]))