summaryrefslogtreecommitdiff
path: root/test/test_text_buffer.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_text_buffer.py')
-rw-r--r--test/test_text_buffer.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test_text_buffer.py b/test/test_text_buffer.py
index 8e9829f4..65c6d9bf 100644
--- a/test/test_text_buffer.py
+++ b/test/test_text_buffer.py
@@ -35,6 +35,13 @@ def msgs_noleave():
msg4 = Message('4', 'f')
return [join, msg3, msg4]
+@fixture(scope='function')
+def msgs_doublejoin():
+ join = MucOwnJoinMessage('join')
+ msg1 = Message('1', 'd')
+ msg2 = Message('2', 'f')
+ join2 = MucOwnJoinMessage('join')
+ return [join, msg1, msg2, join2]
def test_last_message(buf2048):
msg = BaseMessage('toto')
@@ -67,6 +74,24 @@ def test_find_gap(buf2048, msgs_noleave):
assert gap.first_timestamp_after_join == msg3.time
+def test_find_gap_doublejoin(buf2048, msgs_doublejoin):
+ for msg in msgs_doublejoin:
+ buf2048.add_message(msg)
+ gap = buf2048.find_last_gap_muc()
+ assert gap.leave_message == msgs_doublejoin[2]
+ assert gap.join_message == msgs_doublejoin[3]
+
+
+def test_find_gap_doublejoin_no_msg(buf2048):
+ join1 = MucOwnJoinMessage('join')
+ join2 = MucOwnJoinMessage('join')
+ for msg in [join1, join2]:
+ buf2048.add_message(msg)
+ gap = buf2048.find_last_gap_muc()
+ assert gap.leave_message is join1
+ assert gap.join_message is join2
+
+
def test_find_gap_already_filled(buf2048):
msg1 = Message('1', 'q')
msg2 = Message('2', 's')
@@ -115,6 +140,22 @@ def test_get_gap_index(buf2048):
assert buf2048.get_gap_index(gap) == 3
+def test_get_gap_index_doublejoin(buf2048, msgs_doublejoin):
+ for msg in msgs_doublejoin:
+ buf2048.add_message(msg)
+ gap = buf2048.find_last_gap_muc()
+ assert buf2048.get_gap_index(gap) == 3
+
+
+def test_get_gap_index_doublejoin_no_msg(buf2048):
+ join1 = MucOwnJoinMessage('join')
+ join2 = MucOwnJoinMessage('join')
+ for msg in [join1, join2]:
+ buf2048.add_message(msg)
+ gap = buf2048.find_last_gap_muc()
+ assert buf2048.get_gap_index(gap) == 1
+
+
def test_get_gap_index_nojoin(buf2048, msgs_nojoin):
for msg in msgs_nojoin:
buf2048.add_message(msg)