예제 #1
0
 def test_remove_multiple_rows(self):
     self.model.insert_row(Entry('test1'))
     self.model.insert_row(Entry('test2'))
     self.model.insert_row(Entry('test3'))
     self.model.remove_rows(1, 2)
     self.assertEqual(self.model.rowCount(), 1)
     self.assertEqual(self.model.data(self.model.createIndex(0, 1)),
                      'test1')
    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)
 def test_remove_multiple_rows(self):
     self.model.insert_row(Entry("test1"))
     self.model.insert_row(Entry("test2"))
     self.model.insert_row(Entry("test3"))
     self.model.remove_rows([1, 2])
     self.assertEqual(self.model.rowCount(), 1)
     self.assertEqual(self.model.data(self.model.createIndex(0, 1)),
                      "test1")
    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))
예제 #5
0
 def test_create_from_log_msg_with_stamp(self):
     seconds_since_epoch = 100
     msg = Log()
     msg.stamp = Time(sec=seconds_since_epoch, nanosec=0)
     msg.level = int.from_bytes(Log.DEBUG, sys.byteorder)
     entry = Entry.from_ros_msg(msg, use_current_time=False)
     self.assertEqual(entry.date_time.toSecsSinceEpoch(),
                      seconds_since_epoch)
예제 #6
0
 def test_create_from_log_msg_with_stamp(self):
     seconds_since_epoch = 100
     msg = Log()
     msg.header.stamp = rospy.Time(secs=seconds_since_epoch, nsecs=0)
     msg.level = Log.DEBUG
     entry = Entry.from_ros_msg(msg)
     self.assertEqual(entry.date_time.toSecsSinceEpoch(),
                      seconds_since_epoch)
예제 #7
0
 def test_create_from_info_log_msg(self):
     content = "test"
     msg = Log()
     msg.msg = content
     msg.level = int.from_bytes(Log.INFO, sys.byteorder)
     entry = Entry.from_ros_msg(msg)
     self.assertEqual(entry.content, content)
     self.assertFalse(entry.is_error)
     self.assertAlmostEqual(entry.date_time.toSecsSinceEpoch(),
                            QDateTime.currentSecsSinceEpoch(), 10)
예제 #8
0
 def test_insert_multiple_row(self):
     self.model.insert_row(Entry('test1'))
     self.model.insert_row(Entry('test2'))
     self.model.insert_row(Entry('test3'))
     self.assertEqual(self.model.rowCount(), 3)
예제 #9
0
 def test_insert_single_row(self):
     self.model.insert_row(Entry('test'))
     self.assertEqual(self.model.rowCount(), 1)
예제 #10
0
 def test_remove_one_row(self):
     self.model.insert_row(Entry("test"))
     self.model.remove_rows([0])
     self.assertEqual(self.model.rowCount(), 0)
예제 #11
0
 def test_insert_multiple_row(self):
     self.model.insert_row(Entry("test1"))
     self.model.insert_row(Entry("test2"))
     self.model.insert_row(Entry("test3"))
     self.assertEqual(self.model.rowCount(), 3)
예제 #12
0
 def test_create_no_error(self):
     entry = Entry("")
     self.assertFalse(entry.is_error)
예제 #13
0
 def test_remove_rows_out_of_range(self):
     self.model.insert_row(Entry('test2'))
     self.model.remove_rows(2, 2)
     self.assertEqual(self.model.rowCount(), 1)
예제 #14
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")
예제 #15
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))
예제 #16
0
 def test_create_from_fatal_log_msg(self):
     msg = Log()
     msg.level = int.from_bytes(Log.FATAL, sys.byteorder)
     entry = Entry.from_ros_msg(msg)
     self.assertTrue(entry.is_error)
예제 #17
0
 def test_create_with_content(self):
     content = "test"
     entry = Entry(content)
     self.assertEqual(entry.content, content)
예제 #18
0
 def test_remove_one_row(self):
     self.model.insert_row(Entry('test'))
     self.model.remove_rows(0)
     self.assertEqual(self.model.rowCount(), 0)
예제 #19
0
 def test_insert_single_row_count(self):
     entry = Entry("test", QDateTime.fromSecsSinceEpoch(5))
     self.model.insert_row(entry)
     self.assertEqual(self.model.rowCount(), 1)
예제 #20
0
 def test_create_from_fatal_log_msg(self):
     msg = Log()
     msg.level = Log.FATAL
     entry = Entry.from_ros_msg(msg)
     self.assertTrue(entry.is_error)
예제 #21
0
 def test_remove_too_many_rows(self):
     self.model.insert_row(Entry('test'))
     self.model.remove_rows(0, 2)
     self.assertEqual(self.model.rowCount(), 0)
예제 #22
0
 def test_create_from_error_log_msg(self):
     msg = Log()
     msg.level = Log.ERROR
     entry = Entry.from_ros_msg(msg)
     self.assertTrue(entry.is_error)