def test_entry_model_to_string(self):
        entry = Entry("test1", QDateTime.fromSecsSinceEpoch(5))
        self.model.insert_row(entry)
        self.model.insert_row(entry)
        self.model.insert_row(entry)

        self.assertEqual(str(self.model), "{0}\n{0}\n{0}".format(entry))
    def test_insert_single_row(self):
        entry = Entry("test", QDateTime.fromSecsSinceEpoch(5))
        self.model.insert_row(entry)

        time_index = self.model.createIndex(0, 0)
        content_index = self.model.createIndex(0, 1)
        self.assertEqual(self.model.data(time_index), entry.time_string())
        self.assertEqual(self.model.data(content_index), entry.content)
예제 #3
0
    def from_ros_msg(cls, log_msg):
        """Returns an Entry from a given ROS log message.

        :type log_msg: rosgraph_msgs.msg.Log
        :param log_msg: The message to convert
        """
        date_time = (QDateTime.currentDateTime()
                     if log_msg.header.stamp.is_zero() else
                     QDateTime.fromSecsSinceEpoch(log_msg.header.stamp.secs))
        return cls(log_msg.msg, date_time, log_msg.level >= Log.ERROR)
예제 #4
0
    def from_ros_msg(cls, log_msg: Log, use_current_time: Optional[bool] = True):
        """Returns an Entry from a given ROS log message.

        :param log_msg: The message to convert
        :param use_current_time: Whether the current time should be used,
                                instead of the timestamp of the log
        """
        if use_current_time or log_msg.stamp is None:
            date_time = QDateTime.currentDateTime()
        else:
            date_time = QDateTime.fromSecsSinceEpoch(log_msg.stamp.sec)
        return cls(
            log_msg.msg,
            date_time,
            log_msg.level >= int.from_bytes(Log.ERROR, sys.byteorder),
        )
 def test_insert_single_row_count(self):
     entry = Entry("test", QDateTime.fromSecsSinceEpoch(5))
     self.model.insert_row(entry)
     self.assertEqual(self.model.rowCount(), 1)
예제 #6
0
 def test_to_time_string(self):
     date_time = QDateTime.fromSecsSinceEpoch(5, QTimeZone.utc())
     entry = Entry("", date_time)
     self.assertEqual(entry.time_string(), "00:00:05")
예제 #7
0
 def test_to_string(self):
     date_time = QDateTime.fromSecsSinceEpoch(2)
     content = "test"
     entry = Entry(content, date_time)
     self.assertEqual(str(entry),
                      "[{0}] {1}".format(date_time.toString(), content))