Skip to content

Commit ccdacd9

Browse files
authored
make metadata tests compatible with batch parameter (#314)
* make metadata tests compatible with batch parameter We're updating the spec to add a batch parameter to metadata. This makes the tests compatible with both versions of the spec for now; eventually we'll update Ergo and the Unreal module to match the new spec, at which point we can make the batch parameter a hard requirement. * add a test for metadata batch on connect
1 parent 45615f6 commit ccdacd9

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

irctest/server_tests/metadata_2.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from irctest import cases, runner
1212
from irctest.numerics import RPL_METADATASUBOK
13-
from irctest.patma import ANYDICT, ANYLIST, ANYSTR, Either, StrRe
13+
from irctest.patma import ANYDICT, ANYLIST, ANYOPTSTR, ANYSTR, Either, StrRe
1414

1515
CLIENT_NICKS = {
1616
1: "foo",
@@ -24,8 +24,10 @@ def getBatchMessages(self, client):
2424

2525
first_msg = messages.pop(0)
2626
last_msg = messages.pop(-1)
27+
# TODO: s/ANYOPTSTR/ANYSTR/, as per spec update to require a batch parameter
28+
# indicating the target
2729
self.assertMessageMatch(
28-
first_msg, command="BATCH", params=[StrRe(r"\+.*"), "metadata"]
30+
first_msg, command="BATCH", params=[StrRe(r"\+.*"), "metadata", ANYOPTSTR]
2931
)
3032
batch_id = first_msg.params[0][1:]
3133
self.assertMessageMatch(last_msg, command="BATCH", params=["-" + batch_id])
@@ -537,7 +539,36 @@ def testSetGetValidBeforeConnect(self):
537539
self.sendLine(1, "NICK foo")
538540
self.sendLine(1, "USER foo 0 * :foo")
539541
self.sendLine(1, "CAP END")
540-
self.getMessages(1) # consume the reg burst
542+
burst = self.getMessages(1)
543+
544+
burst_batch = []
545+
batch_id = ""
546+
for msg in burst:
547+
if (
548+
batch_id == ""
549+
and msg.command == "BATCH"
550+
and len(msg.params) >= 3
551+
and msg.params[1] == "metadata"
552+
):
553+
batch_id = msg.params[0][1:]
554+
elif batch_id != "":
555+
if msg.command == "BATCH" and msg.params[0] == "-" + batch_id:
556+
batch_id = ""
557+
else:
558+
burst_batch.append(msg)
559+
self.assertGreater(
560+
len(burst_batch), 0, "Must receive METADATA lines for pre-set metadata"
561+
)
562+
self.assertTrue(
563+
any(
564+
self.messageEqual(
565+
msg,
566+
command="METADATA",
567+
params=["foo", "display-name", ANYSTR, "Foo The First"],
568+
)
569+
for msg in burst_batch
570+
)
571+
)
541572

542573
self.assertGetValue(1, "*", "display-name", "Foo The First")
543574

0 commit comments

Comments
 (0)