Esempio n. 1
0
 def pop_messages(self, counter, timeout=DEFAULT_TIMEOUT):
     assert wait_until_true_custom(self.__buffer_and_parse, args=(counter,), timeout=timeout) is True
     counter = self.__map_counter(counter)
     required_number_of_messages = self.__parser.msg_list[0:counter]
     self.__parser.msg_list = self.__parser.msg_list[
         counter:
     ]  # remove messages from the beginning of the msg_list, this is why we call it pop
     return required_number_of_messages
Esempio n. 2
0
 def peek_messages(self, counter):
     assert (
         wait_until_true_custom(self.__buffer_and_parse, args=(counter, ))
     ), "\nExpected message counter: [{}]\nArrived message counter: [{}]\nArrived messages: [{}]".format(
         counter, len(self.__parser.msg_list), self.__parser.msg_list)
     counter = self.__map_counter(counter)
     required_number_of_messages = self.__parser.msg_list[0:counter]
     return required_number_of_messages
Esempio n. 3
0
 def pop_messages(self, counter, timeout=DEFAULT_TIMEOUT):
     assert (
         wait_until_true_custom(self.__buffer_and_parse,
                                args=(counter, ),
                                timeout=timeout)
     ), "\nExpected message counter: [{}]\nArrived message counter: [{}]\nArrived messages: [{}]".format(
         counter, len(self.__parser.msg_list), self.__parser.msg_list)
     counter = self.__map_counter(counter)
     required_number_of_messages = self.__parser.msg_list[0:counter]
     self.__parser.msg_list = self.__parser.msg_list[
         counter:]  # remove messages from the beginning of the msg_list, this is why we call it pop
     return required_number_of_messages
Esempio n. 4
0
    def wait_for_lines(self, lines, timeout=DEFAULT_TIMEOUT):
        def find_lines_in_file(lines_to_find, lines_found, f):
            line_read = f.readline()
            if not line_read and lines_to_find:
                return False
            for line_to_find in lines_to_find:
                if line_to_find in line_read:
                    lines_found.append(line_read)
                    lines_to_find.remove(line_to_find)
                    break
            everything_is_found = lines_to_find == []
            return everything_is_found

        lines_found = []
        if not wait_until_true_custom(find_lines_in_file, (lines, lines_found, self), timeout=timeout, poll_freq=0):
            raise Exception("Could not find all lines in {}. Remaining lines to find: {} Lines found: {}".format(self.path, lines, lines_found))

        return lines_found
Esempio n. 5
0
 def peek_messages(self, counter):
     assert wait_until_true_custom(self.__buffer_and_parse, args=(counter,)) is True
     counter = self.__map_counter(counter)
     required_number_of_messages = self.__parser.msg_list[0:counter]
     return required_number_of_messages
Esempio n. 6
0
def test_wait_until_true_custom_returns_with_result():
    assert wait_until_true_custom(inner_function_add_numbers, timeout=0.1) == 5
Esempio n. 7
0
def test_wait_until_true_custom_inner_function_returns_false():
    assert wait_until_true_custom(inner_function_return_false,
                                  timeout=0.1) is False
Esempio n. 8
0
def test_wait_until_true_inner_function_returns_true():
    assert wait_until_true_custom(inner_function_return_true, timeout=0.1)