summaryrefslogtreecommitdiff
path: root/test/test_text_buffer.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-22 17:09:17 +0200
committermathieui <mathieui@mathieui.net>2020-05-23 16:10:13 +0200
commit29eef159d50c836fbd7a27770775d63700dc7f19 (patch)
treeae17eb3f41a87974b6c9af0f3335ffa5a4b5fe17 /test/test_text_buffer.py
parentd3655c4c3520f1a86af5ccf7b816076ae1d18312 (diff)
downloadpoezio-29eef159d50c836fbd7a27770775d63700dc7f19.tar.gz
poezio-29eef159d50c836fbd7a27770775d63700dc7f19.tar.bz2
poezio-29eef159d50c836fbd7a27770775d63700dc7f19.tar.xz
poezio-29eef159d50c836fbd7a27770775d63700dc7f19.zip
Fix some edge cases of MAM history fetch
- Wait until we receive our own MUC presence to fetch history - Fix /reconnect weirdness
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)