Skip to content

Commit e943e2c

Browse files
authored
fix metadata before-connect test (#312)
* Accept `*` as the nick for the numeric before connection registration is complete. It was already accepted as the target, but the nick for the numeric is a separate parameter * `skipToWelcome` skips past 001, but we need to skip the entire reg burst
1 parent b32cd08 commit e943e2c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

irctest/server_tests/metadata_2.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,20 @@ def testListInvalidTarget(self):
142142
"and then 762 (RPL_METADATAEND)",
143143
)
144144

145-
def assertSetValue(self, client, target, key, value):
145+
def assertSetValue(self, client, target, key, value, before_connect=False):
146146
self.sendLine(client, "METADATA {} SET {} :{}".format(target, key, value))
147147

148148
if target == "*":
149149
target = StrRe(r"(\*|" + CLIENT_NICKS[client] + ")")
150150

151+
nick = CLIENT_NICKS[client]
152+
if before_connect:
153+
nick = StrRe(r"(\*|" + CLIENT_NICKS[client] + ")")
154+
151155
self.assertMessageMatch(
152156
self.getMessage(client),
153157
command="761", # RPL_KEYVALUE
154-
params=[CLIENT_NICKS[client], target, key, ANYSTR, value],
158+
params=[nick, target, key, ANYSTR, value],
155159
)
156160

157161
def assertUnsetValue(self, client, target, key):
@@ -166,18 +170,22 @@ def assertUnsetValue(self, client, target, key):
166170
params=[CLIENT_NICKS[client], target, key, ANYSTR],
167171
)
168172

169-
def assertGetValue(self, client, target, key, value):
173+
def assertGetValue(self, client, target, key, value, before_connect=False):
170174
self.sendLine(client, "METADATA {} GET {}".format(target, key))
171175

172176
if target == "*":
173177
target = StrRe(r"(\*|" + CLIENT_NICKS[client] + ")")
174178

179+
nick = CLIENT_NICKS[client]
180+
if before_connect:
181+
nick = StrRe(r"(\*|" + CLIENT_NICKS[client] + ")")
182+
175183
(batch_id, messages) = self.getBatchMessages(client)
176184
self.assertEqual(len(messages), 1, fail_msg="Expected one RPL_KEYVALUE")
177185
self.assertMessageMatch(
178186
messages[0],
179187
command="761", # RPL_KEYVALUE
180-
params=[CLIENT_NICKS[client], target, key, ANYSTR, value],
188+
params=[nick, target, key, ANYSTR, value],
181189
)
182190

183191
def assertValueNotSet(self, client, target, key):
@@ -522,12 +530,14 @@ def testSetGetValidBeforeConnect(self):
522530

523531
self.requestCapabilities(1, ["draft/metadata-2", "batch"], skip_if_cap_nak=True)
524532

525-
self.assertSetValue(1, "*", "display-name", "Foo The First")
533+
self.assertSetValue(
534+
1, "*", "display-name", "Foo The First", before_connect=True
535+
)
526536

527537
self.sendLine(1, "NICK foo")
528538
self.sendLine(1, "USER foo 0 * :foo")
529539
self.sendLine(1, "CAP END")
530-
self.skipToWelcome(1)
540+
self.getMessages(1) # consume the reg burst
531541

532542
self.assertGetValue(1, "*", "display-name", "Foo The First")
533543

0 commit comments

Comments
 (0)