Skip to content

Commit 2e03ba5

Browse files
committed
fix: normalize mention format in tests to handle both <@id> and @id
1 parent 9107b39 commit 2e03ba5

3 files changed

Lines changed: 41 additions & 38 deletions

File tree

csp_bot_commands/tests/test_fun.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -73,78 +73,79 @@ def test_execute(self, args):
7373
assert msg is not None
7474
assert msg.backend == "slack"
7575
assert msg.channel == "test_channel"
76+
msg_text = msg.msg.replace("<@", "@").replace(">", "")
7677

7778
if args[0] == "icelandic":
78-
assert msg.msg.startswith("@123 consoles @456 with an Icelandic folk saying:")
79+
assert msg_text.startswith("@123 consoles @456 with an Icelandic folk saying:")
7980
elif args[0] == "german":
80-
assert msg.msg.startswith("@123 teaches @456 some German:")
81+
assert msg_text.startswith("@123 teaches @456 some German:")
8182
elif args[0] == "cocktail":
82-
assert msg.msg.startswith("@123 calls @456 over to the")
83+
assert msg_text.startswith("@123 calls @456 over to the")
8384
elif args[0] == "beer":
84-
assert msg.msg.startswith("@123 calls @456 over to the")
85+
assert msg_text.startswith("@123 calls @456 over to the")
8586
elif args[0] == "dune":
86-
assert msg.msg.startswith("@123 scrapes wisdom for @456 off the sands of Arrakis:")
87+
assert msg_text.startswith("@123 scrapes wisdom for @456 off the sands of Arrakis:")
8788
elif args[0] == "bush":
88-
assert msg.msg.startswith("@123 impresses @456 with a quote from George W. Bush:")
89+
assert msg_text.startswith("@123 impresses @456 with a quote from George W. Bush:")
8990
elif args[0] == "shakespeare":
90-
assert msg.msg.startswith("@123 hurls a Shakespearean insult at @456:")
91+
assert msg_text.startswith("@123 hurls a Shakespearean insult at @456:")
9192
elif args[0] == "yogi":
92-
assert msg.msg.startswith("@123 shares some Yogi Berra wisdom with @456:")
93+
assert msg_text.startswith("@123 shares some Yogi Berra wisdom with @456:")
9394
elif args[0] == "tolkien":
94-
assert msg.msg.startswith("@123 offers @456 wisdom from Middle-earth:")
95+
assert msg_text.startswith("@123 offers @456 wisdom from Middle-earth:")
9596
elif args[0] == "fortune":
96-
assert msg.msg.startswith("@123 cracks open a fortune cookie for @456:")
97+
assert msg_text.startswith("@123 cracks open a fortune cookie for @456:")
9798
elif args[0] == "pratchett":
98-
assert msg.msg.startswith("@123 enlightens @456 with Pratchett:")
99+
assert msg_text.startswith("@123 enlightens @456 with Pratchett:")
99100
elif args[0] == "wilde":
100-
assert msg.msg.startswith("@123 graces @456 with an Oscar Wilde quip:")
101+
assert msg_text.startswith("@123 graces @456 with an Oscar Wilde quip:")
101102
elif args[0] == "wine":
102-
assert msg.msg.startswith("@123 calls @456 over to the")
103+
assert msg_text.startswith("@123 calls @456 over to the")
103104
elif args[0] == "nietzsche":
104-
assert msg.msg.startswith("@123 darkly enlightens @456 with Nietzsche:")
105+
assert msg_text.startswith("@123 darkly enlightens @456 with Nietzsche:")
105106
elif args[0] == "twain":
106-
assert msg.msg.startswith("@123 shares a Mark Twain quip with @456:")
107+
assert msg_text.startswith("@123 shares a Mark Twain quip with @456:")
107108
elif args[0] == "zen":
108-
assert msg.msg.startswith("@123 offers @456 a moment of zen:")
109+
assert msg_text.startswith("@123 offers @456 a moment of zen:")
109110
elif args[0] == "stoic":
110-
assert msg.msg.startswith("@123 offers @456 some Stoic counsel:")
111+
assert msg_text.startswith("@123 offers @456 some Stoic counsel:")
111112
elif args[0] == "churchill":
112-
assert msg.msg.startswith("@123 channels Churchill for @456:")
113+
assert msg_text.startswith("@123 channels Churchill for @456:")
113114
elif args[0] == "confucius":
114-
assert msg.msg.startswith("@123 shares ancient wisdom with @456:")
115+
assert msg_text.startswith("@123 shares ancient wisdom with @456:")
115116
elif args[0] == "starwars":
116-
assert msg.msg.startswith("@123 reaches for the Force on behalf of @456:")
117+
assert msg_text.startswith("@123 reaches for the Force on behalf of @456:")
117118
elif args[0] == "hitch":
118-
assert msg.msg.startswith("@123 consults the Guide for @456:")
119+
assert msg_text.startswith("@123 consults the Guide for @456:")
119120
elif args[0] == "hemingway":
120-
assert msg.msg.startswith("@123 pours a drink and quotes Hemingway for @456:")
121+
assert msg_text.startswith("@123 pours a drink and quotes Hemingway for @456:")
121122
elif args[0] == "dad":
122-
assert msg.msg.startswith("@123 subjects @456 to a dad joke:")
123+
assert msg_text.startswith("@123 subjects @456 to a dad joke:")
123124
elif args[0] == "chuck":
124-
assert msg.msg.startswith("@123 informs @456 of a Chuck Norris fact:")
125+
assert msg_text.startswith("@123 informs @456 of a Chuck Norris fact:")
125126
elif args[0] == "soviet":
126-
assert msg.msg.startswith("@123 reminds @456:")
127+
assert msg_text.startswith("@123 reminds @456:")
127128
elif args[0] == "conspiracy":
128-
assert msg.msg.startswith("@123 whispers to @456:")
129+
assert msg_text.startswith("@123 whispers to @456:")
129130
elif args[0] == "magic8":
130-
assert msg.msg.startswith("@123 shakes the Magic 8-Ball for @456:")
131+
assert msg_text.startswith("@123 shakes the Magic 8-Ball for @456:")
131132
elif args[0] == "compliment":
132-
assert msg.msg.startswith("@123 lavishes praise on @456:")
133+
assert msg_text.startswith("@123 lavishes praise on @456:")
133134
elif args[0] == "latin":
134-
assert msg.msg.startswith("@123 schools @456 in Latin:")
135+
assert msg_text.startswith("@123 schools @456 in Latin:")
135136
elif args[0] == "pirate":
136-
assert msg.msg.startswith("@123 makes @456 walk the plank:")
137+
assert msg_text.startswith("@123 makes @456 walk the plank:")
137138
elif args[0] == "corporate":
138-
assert msg.msg.startswith("@123 synergizes with @456:")
139+
assert msg_text.startswith("@123 synergizes with @456:")
139140
elif args[0] == "motivational":
140-
assert msg.msg.startswith("@123 puts a poster on @456")
141+
assert msg_text.startswith("@123 puts a poster on @456")
141142
elif args[0] == "haiku":
142-
assert msg.msg.startswith("@123 composes a haiku for @456:")
143+
assert msg_text.startswith("@123 composes a haiku for @456:")
143144
elif args[0] == "programming":
144-
assert msg.msg.startswith("@123 shares a programming joke with @456:")
145+
assert msg_text.startswith("@123 shares a programming joke with @456:")
145146
elif args[0] == "whiskey":
146-
assert msg.msg.startswith("@123 calls @456 over to the")
147+
assert msg_text.startswith("@123 calls @456 over to the")
147148
elif args[0] == "highfive":
148-
assert msg.msg.startswith("@123 gives @456 a magnificent")
149+
assert msg_text.startswith("@123 gives @456 a magnificent")
149150
else:
150151
assert False

csp_bot_commands/tests/test_thanks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ def test_execute(self, args):
3737
assert msg is not None
3838
assert msg.backend == "slack"
3939
assert msg.channel == "test_channel"
40-
assert msg.msg.startswith("@123 thanks @456 with")
40+
msg_text = msg.msg.replace("<@", "@").replace(">", "")
41+
assert msg_text.startswith("@123 thanks @456 with")

csp_bot_commands/tests/test_trout.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def test_execute(self, args):
3737
assert msg is not None
3838
assert msg.backend == "slack"
3939
assert msg.channel == "test_channel"
40-
assert msg.msg.startswith("@123 slaps @456 with")
40+
msg_text = msg.msg.replace("<@", "@").replace(">", "")
41+
assert msg_text.startswith("@123 slaps @456 with")
4142
if args[0] == "trout":
4243
assert "trout" in msg.msg

0 commit comments

Comments
 (0)