mirror of
https://github.com/progval/irctest.git
synced 2025-04-05 23:09:48 +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,172 +470,195 @@ 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)
|
||||||
|
|
||||||
self.sendLine(
|
if self._supports_msgid():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY LATEST %s msgid=%s %d"
|
user,
|
||||||
% (chname, echo_messages[4].msgid, INCLUSIVE_LIMIT),
|
"CHATHISTORY LATEST %s msgid=%s %d"
|
||||||
)
|
% (chname, echo_messages[4].msgid, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[5:], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[5:], result)
|
||||||
|
|
||||||
self.sendLine(
|
if self._supports_timestamp():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY LATEST %s timestamp=%s %d"
|
user,
|
||||||
% (chname, echo_messages[4].time, INCLUSIVE_LIMIT),
|
"CHATHISTORY LATEST %s timestamp=%s %d"
|
||||||
)
|
% (chname, echo_messages[4].time, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[5:], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[5:], result)
|
||||||
|
|
||||||
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
|
||||||
self.sendLine(
|
if self._supports_msgid():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY BEFORE %s msgid=%s %d"
|
user,
|
||||||
% (chname, echo_messages[6].msgid, INCLUSIVE_LIMIT),
|
"CHATHISTORY BEFORE %s msgid=%s %d"
|
||||||
)
|
% (chname, echo_messages[6].msgid, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[:6], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[:6], result)
|
||||||
|
|
||||||
self.sendLine(
|
if self._supports_timestamp():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
user,
|
||||||
% (chname, echo_messages[6].time, INCLUSIVE_LIMIT),
|
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
||||||
)
|
% (chname, echo_messages[6].time, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[:6], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[:6], result)
|
||||||
|
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
"CHATHISTORY BEFORE %s timestamp=%s %d"
|
||||||
% (chname, echo_messages[6].time, 2),
|
% (chname, echo_messages[6].time, 2),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[4:6], result)
|
self.assertEqual(echo_messages[4:6], result)
|
||||||
|
|
||||||
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
|
||||||
self.sendLine(
|
if self._supports_msgid():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY AFTER %s msgid=%s %d"
|
user,
|
||||||
% (chname, echo_messages[3].msgid, INCLUSIVE_LIMIT),
|
"CHATHISTORY AFTER %s msgid=%s %d"
|
||||||
)
|
% (chname, echo_messages[3].msgid, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[4:], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[4:], result)
|
||||||
|
|
||||||
self.sendLine(
|
if self._supports_timestamp():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY AFTER %s timestamp=%s %d"
|
user,
|
||||||
% (chname, echo_messages[3].time, INCLUSIVE_LIMIT),
|
"CHATHISTORY AFTER %s timestamp=%s %d"
|
||||||
)
|
% (chname, echo_messages[3].time, INCLUSIVE_LIMIT),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[4:], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[4:], result)
|
||||||
|
|
||||||
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)
|
)
|
||||||
self.assertEqual(echo_messages[4:7], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
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
|
||||||
# BETWEEN forwards and backwards
|
if self._supports_msgid():
|
||||||
self.sendLine(
|
# BETWEEN forwards and backwards
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
user,
|
||||||
% (
|
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
||||||
chname,
|
% (
|
||||||
echo_messages[0].msgid,
|
chname,
|
||||||
echo_messages[-1].msgid,
|
echo_messages[0].msgid,
|
||||||
INCLUSIVE_LIMIT,
|
echo_messages[-1].msgid,
|
||||||
),
|
INCLUSIVE_LIMIT,
|
||||||
)
|
),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertEqual(echo_messages[1:-1], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[1:-1], result)
|
||||||
|
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
||||||
% (
|
% (
|
||||||
chname,
|
chname,
|
||||||
echo_messages[-1].msgid,
|
echo_messages[-1].msgid,
|
||||||
echo_messages[0].msgid,
|
echo_messages[0].msgid,
|
||||||
INCLUSIVE_LIMIT,
|
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)
|
||||||
|
|
||||||
# BETWEEN forwards and backwards with a limit, should get
|
# BETWEEN forwards and backwards with a limit, should get
|
||||||
# different results this time
|
# different results this time
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
||||||
% (chname, echo_messages[0].msgid, echo_messages[-1].msgid, 3),
|
% (chname, echo_messages[0].msgid, echo_messages[-1].msgid, 3),
|
||||||
)
|
)
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
self.assertEqual(echo_messages[1:4], result)
|
self.assertEqual(echo_messages[1:4], result)
|
||||||
|
|
||||||
self.sendLine(
|
self.sendLine(
|
||||||
user,
|
user,
|
||||||
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
"CHATHISTORY BETWEEN %s msgid=%s msgid=%s %d"
|
||||||
% (chname, echo_messages[-1].msgid, echo_messages[0].msgid, 3),
|
% (chname, echo_messages[-1].msgid, echo_messages[0].msgid, 3),
|
||||||
)
|
)
|
||||||
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)
|
||||||
|
|
||||||
# same stuff again but with timestamps
|
if self._supports_timestamp():
|
||||||
self.sendLine(
|
# same stuff again but with timestamps
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
user,
|
||||||
% (chname, echo_messages[0].time, echo_messages[-1].time, INCLUSIVE_LIMIT),
|
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
||||||
)
|
% (
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
chname,
|
||||||
self.assertEqual(echo_messages[1:-1], result)
|
echo_messages[0].time,
|
||||||
self.sendLine(
|
echo_messages[-1].time,
|
||||||
user,
|
INCLUSIVE_LIMIT,
|
||||||
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
),
|
||||||
% (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)
|
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, 3),
|
chname,
|
||||||
)
|
echo_messages[-1].time,
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
echo_messages[0].time,
|
||||||
self.assertEqual(echo_messages[1:4], result)
|
INCLUSIVE_LIMIT,
|
||||||
self.sendLine(
|
),
|
||||||
user,
|
)
|
||||||
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
% (chname, echo_messages[-1].time, echo_messages[0].time, 3),
|
self.assertEqual(echo_messages[1:-1], result)
|
||||||
)
|
self.sendLine(
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
user,
|
||||||
self.assertEqual(echo_messages[-4:-1], result)
|
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
||||||
|
% (chname, echo_messages[0].time, echo_messages[-1].time, 3),
|
||||||
|
)
|
||||||
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[1:4], result)
|
||||||
|
self.sendLine(
|
||||||
|
user,
|
||||||
|
"CHATHISTORY BETWEEN %s timestamp=%s timestamp=%s %d"
|
||||||
|
% (chname, echo_messages[-1].time, echo_messages[0].time, 3),
|
||||||
|
)
|
||||||
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
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):
|
||||||
self.sendLine(
|
if self._supports_msgid():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY AROUND %s msgid=%s %d" % (chname, echo_messages[7].msgid, 1),
|
user,
|
||||||
)
|
"CHATHISTORY AROUND %s msgid=%s %d"
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
% (chname, echo_messages[7].msgid, 1),
|
||||||
self.assertEqual([echo_messages[7]], result)
|
)
|
||||||
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
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)
|
)
|
||||||
self.assertEqual(echo_messages[6:9], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertEqual(echo_messages[6:9], result)
|
||||||
|
|
||||||
self.sendLine(
|
if self._supports_timestamp():
|
||||||
user,
|
self.sendLine(
|
||||||
"CHATHISTORY AROUND %s timestamp=%s %d"
|
user,
|
||||||
% (chname, echo_messages[7].time, 3),
|
"CHATHISTORY AROUND %s timestamp=%s %d"
|
||||||
)
|
% (chname, echo_messages[7].time, 3),
|
||||||
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
)
|
||||||
self.assertIn(echo_messages[7], result)
|
result = self.validate_chathistory_batch(self.getMessages(user), chname)
|
||||||
|
self.assertIn(echo_messages[7], result)
|
||||||
|
|
||||||
@pytest.mark.arbitrary_client_tags
|
@pytest.mark.arbitrary_client_tags
|
||||||
@skip_ngircd
|
@skip_ngircd
|
||||||
|
Reference in New Issue
Block a user