from scenarios import *
scenario = (
scenarios.simple_channel_join.scenario,
# Send two channel messages
send_stanza("coucou"),
expect_stanza("/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou']",
"/message/stable_id:stanza-id[@by='#foo%{irc_server_one}'][@id]"),
send_stanza("coucou 2"),
expect_stanza("/message[@from='#foo%{irc_server_one}/{nick_one}'][@to='{jid_one}/{resource_one}'][@type='groupchat']/body[text()='coucou 2']"),
# Retrieve the complete archive
send_stanza(""),
expect_stanza("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay",
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou']"),
expect_stanza("/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay",
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 2']"),
expect_stanza("/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']",
"/iq/mam:fin/rms:set/rsm:last",
"/iq/mam:fin/rsm:set/rsm:first",
"/iq/mam:fin[@complete='true']"),
# Retrieve an empty archive by specifying an early “end” date
send_stanza("""
urn:xmpp:mam:2
2000-06-07T00:00:00Z
"""),
expect_stanza("/iq[@type='result'][@id='id2'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']",
"/iq/mam:fin[@complete='true']/rsm:set"),
# Retrieve an empty archive by specifying a late “start” date
# (note that this test will break in ~1000 years)
send_stanza("""
urn:xmpp:mam:2
3016-06-07T00:00:00Z
"""),
expect_stanza("/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']",
"/iq/mam:fin[@complete='true']/rsm:set"),
# Retrieve the whole archive, but limit the response to one elemet
send_stanza("1"),
expect_stanza("/message/mam:result[@queryid='qid4']/forward:forwarded/delay:delay",
"/message/mam:result[@queryid='qid4']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou']"),
expect_stanza("/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']",
"!/iq/mam:fin[@complete='true']/rsm:set"),
)