mirror of
https://github.com/progval/irctest.git
synced 2025-04-06 15:29:50 +00:00
chathistory: Skip assertions based on MSGREFTYPES (#263)
This will be useful to test Sable, which does not support CHATHISTORY with msgid= yet
This commit is contained in:
@ -58,6 +58,16 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
def config() -> cases.TestCaseControllerConfig:
|
def config() -> cases.TestCaseControllerConfig:
|
||||||
return cases.TestCaseControllerConfig(chathistory=True)
|
return cases.TestCaseControllerConfig(chathistory=True)
|
||||||
|
|
||||||
|
def _supports_msgid(self):
|
||||||
|
return "msgid" in self.server_support.get(
|
||||||
|
"MSGREFTYPES", "msgid,timestamp"
|
||||||
|
).split(",")
|
||||||
|
|
||||||
|
def _supports_timestamp(self):
|
||||||
|
return "timestamp" in self.server_support.get(
|
||||||
|
"MSGREFTYPES", "msgid,timestamp"
|
||||||
|
).split(",")
|
||||||
|
|
||||||
@skip_ngircd
|
@skip_ngircd
|
||||||
def testInvalidTargets(self):
|
def testInvalidTargets(self):
|
||||||
bar, pw = random_name("bar"), random_name("pw")
|
bar, pw = random_name("bar"), random_name("pw")
|
||||||
@ -460,6 +470,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[-1:], result)
|
self.assertEqual(echo_messages[-1:], result)
|
||||||
|
|
||||||
|
if self._supports_msgid():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY LATEST %s msgid=%s %d"
|
"CHATHISTORY LATEST %s msgid=%s %d"
|
||||||
@ -468,6 +479,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[5:], result)
|
self.assertEqual(echo_messages[5:], result)
|
||||||
|
|
||||||
|
if self._supports_timestamp():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY LATEST %s timestamp=%s %d"
|
"CHATHISTORY LATEST %s timestamp=%s %d"
|
||||||
@ -478,6 +490,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
|
|
||||||
def _validate_chathistory_BEFORE(self, echo_messages, user, chname):
|
def _validate_chathistory_BEFORE(self, echo_messages, user, chname):
|
||||||
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
||||||
|
if self._supports_msgid():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BEFORE %s msgid=%s %d"
|
"CHATHISTORY BEFORE %s msgid=%s %d"
|
||||||
@ -486,6 +499,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[:6], result)
|
self.assertEqual(echo_messages[:6], result)
|
||||||
|
|
||||||
|
if self._supports_timestamp():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
||||||
@ -504,6 +518,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
|
|
||||||
def _validate_chathistory_AFTER(self, echo_messages, user, chname):
|
def _validate_chathistory_AFTER(self, echo_messages, user, chname):
|
||||||
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
||||||
|
if self._supports_msgid():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AFTER %s msgid=%s %d"
|
"CHATHISTORY AFTER %s msgid=%s %d"
|
||||||
@ -512,6 +527,7 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[4:], result)
|
self.assertEqual(echo_messages[4:], result)
|
||||||
|
|
||||||
|
if self._supports_timestamp():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AFTER %s timestamp=%s %d"
|
"CHATHISTORY AFTER %s timestamp=%s %d"
|
||||||
@ -522,13 +538,15 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
|
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AFTER %s timestamp=%s %d" % (chname, echo_messages[3].time, 3),
|
"CHATHISTORY AFTER %s timestamp=%s %d"
|
||||||
|
% (chname, echo_messages[3].time, 3),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[4:7], result)
|
self.assertEqual(echo_messages[4:7], result)
|
||||||
|
|
||||||
def _validate_chathistory_BETWEEN(self, echo_messages, user, chname):
|
def _validate_chathistory_BETWEEN(self, echo_messages, user, chname):
|
||||||
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
INCLUSIVE_LIMIT = len(echo_messages) * 2
|
||||||
|
if self._supports_msgid():
|
||||||
# BETWEEN forwards and backwards
|
# BETWEEN forwards and backwards
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
@ -574,18 +592,29 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[-4:-1], result)
|
self.assertEqual(echo_messages[-4:-1], result)
|
||||||
|
|
||||||
|
if self._supports_timestamp():
|
||||||
# same stuff again but with timestamps
|
# same stuff again but with timestamps
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
||||||
% (chname, echo_messages[0].time, echo_messages[-1].time, INCLUSIVE_LIMIT),
|
% (
|
||||||
|
chname,
|
||||||
|
echo_messages[0].time,
|
||||||
|
echo_messages[-1].time,
|
||||||
|
INCLUSIVE_LIMIT,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[1:-1], result)
|
self.assertEqual(echo_messages[1:-1], result)
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
||||||
% (chname, echo_messages[-1].time, echo_messages[0].time, INCLUSIVE_LIMIT),
|
% (
|
||||||
|
chname,
|
||||||
|
echo_messages[-1].time,
|
||||||
|
echo_messages[0].time,
|
||||||
|
INCLUSIVE_LIMIT,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[1:-1], result)
|
self.assertEqual(echo_messages[1:-1], result)
|
||||||
@ -605,20 +634,24 @@ class ChathistoryTestCase(cases.BaseServerTestCase):
|
|||||||
self.assertEqual(echo_messages[-4:-1], result)
|
self.assertEqual(echo_messages[-4:-1], result)
|
||||||
|
|
||||||
def _validate_chathistory_AROUND(self, echo_messages, user, chname):
|
def _validate_chathistory_AROUND(self, echo_messages, user, chname):
|
||||||
|
if self._supports_msgid():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AROUND %s msgid=%s %d" % (chname, echo_messages[7].msgid, 1),
|
"CHATHISTORY AROUND %s msgid=%s %d"
|
||||||
|
% (chname, echo_messages[7].msgid, 1),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual([echo_messages[7]], result)
|
self.assertEqual([echo_messages[7]], result)
|
||||||
|
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AROUND %s msgid=%s %d" % (chname, echo_messages[7].msgid, 3),
|
"CHATHISTORY AROUND %s msgid=%s %d"
|
||||||
|
% (chname, echo_messages[7].msgid, 3),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[6:9], result)
|
self.assertEqual(echo_messages[6:9], result)
|
||||||
|
|
||||||
|
if self._supports_timestamp():
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY AROUND %s timestamp=%s %d"
|
"CHATHISTORY AROUND %s timestamp=%s %d"
|
||||||
|
Reference in New Issue
Block a user