示例#1
0
def test_write_pre_basemsg(buffer):
    str_time = '10:11:12'
    time = datetime.strptime(str_time, '%H:%M:%S')
    msg = BaseMessage(txt='coucou', time=time)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '10:11:12 '
    assert size == len(buffer.text)
示例#2
0
 def refresh(self) -> None:
     log.debug('Refresh: %s', self.__class__.__name__)
     if self.height <= 0:
         return
     if self.pos == 0:
         lines = self.built_lines[-self.height:]
     else:
         lines = self.built_lines[-self.height - self.pos:-self.pos]
     with_timestamps = config.get("show_timestamps")
     nick_size = config.get("max_nick_length")
     self._win.move(0, 0)
     self._win.erase()
     offset = 0
     for y, line in enumerate(lines):
         if line:
             msg = line.msg
             if line.start_pos == 0:
                 offset = write_pre(msg, self, with_timestamps, nick_size)
             elif y == 0:
                 offset = msg.compute_offset(with_timestamps,
                                             nick_size)
             self.write_text(
                 y, offset,
                 line.prepend + line.msg.txt[line.start_pos:line.end_pos])
         else:
             self.write_line_separator(y)
         if y != self.height - 1:
             self.addstr('\n')
     self._win.attrset(0)
     self._refresh()
示例#3
0
def test_write_pre_message_nack(buffer, time):
    nack = get_theme().CHAR_NACK
    expected = '10:11:12 %s toto> ' % nack
    msg = Message(txt='coucou', nickname='toto', time=time, ack=-1)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == expected
    assert size == len(buffer.text)
示例#4
0
def test_write_pre_message_me(buffer, time):
    msg = Message(txt='/me coucou', nickname='toto', time=time)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '10:11:12 * toto '
    assert size == len(buffer.text)
示例#5
0
def test_write_pre_message_no_timestamp(buffer):
    msg = Message(txt='coucou', nickname='toto')
    size = write_pre(msg, buffer, False, 10)
    assert buffer.text == 'toto> '
    assert size == len(buffer.text)
示例#6
0
def test_write_pre_message_highlight(buffer, time):
    msg = Message(txt='coucou', nickname='toto', time=time, highlight=True)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '10:11:12 toto> '
    assert size == len(buffer.text)
示例#7
0
def test_write_pre_message_simple_history(buffer, time):
    msg = Message(txt='coucou', nickname='toto', time=time, history=True)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '2019-09-27 10:11:12 toto> '
    assert size == len(buffer.text)
示例#8
0
def test_write_pre_xmllog_out(buffer):
    msg = XMLLog(txt="coucou", incoming=False)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '%s OUT ' % msg.time.strftime('%H:%M:%S')
    assert size == len(buffer.text)
示例#9
0
def test_write_pre_message_revisions(buffer, time):
    msg = Message(txt='coucou', nickname='toto', time=time, revisions=5)
    size = write_pre(msg, buffer, True, 10)
    assert buffer.text == '10:11:12 toto5> '
    assert size == len(buffer.text)