Skip to content

Commit

Permalink
split up tests for seen
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasw committed Oct 8, 2023
1 parent de89e81 commit 0aec1ff
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions plugins/Seen/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,10 @@ def testSeen(self):
self.assertNotError('seen last')
self.assertNotError('list')
self.assertNotError('config plugins.Seen.minimumNonWildcard 2')
self.assertError('seen *')
self.assertNotError('seen %s' % self.nick)
# Test case: 'seen' with a nick (user in channel)
self.assertRegexp('seen %s' % self.nick, 'is in the channel now')
m = self.assertNotError('seen %s' % self.nick.upper())
self.assertIn(self.nick.upper(), m.args[1])
self.assertRegexp('seen user %s' % self.nick,
'^%s was last seen' % self.nick)
# Test case: 'seen' with a user (user in channel)
self.assertRegexp('seen user %s' % self.nick, 'is in the channel now')
# Test case: 'seen' with a nick (user not in channel)
testnick = "user123"
self.irc.feedMsg(ircmsgs.join(self.channel, testnick, "user123!baz"))
self.irc.feedMsg(ircmsgs.part(self.channel, prefix="user123!baz"))
self.assertError('seen *')
self.assertNotError('seen %s' % self.nick)
self.assertNotRegexp("seen %s" % testnick, "is in the channel now")
self.assertNotError('config plugins.Seen.minimumNonWildcard 0')
orig = conf.supybot.protocols.irc.strictRfc()
try:
Expand All @@ -112,6 +100,27 @@ def testSeen(self):
conf.supybot.protocols.irc.strictRfc.setValue(orig)


def testSeenNickInChannel(self):
# Test case: 'seen' with a nick (user in channel)
self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick,
prefix=self.prefix))
self.assertRegexp('seen %s' % self.nick, 'is in the channel right now')
m = self.assertNotError('seen %s' % self.nick.upper())
self.assertIn(self.nick.upper(), m.args[1])

def testSeenUserInChannel(self):
# Test case: 'seen' with a user (user in channel)
self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick,
prefix=self.prefix))
self.assertRegexp('seen user %s' % self.nick, 'is in the channel right now')

def testSeenNickNotInChannel(self):
# Test case: 'seen' with a nick (user not in channel)
testnick = "user123"
self.irc.feedMsg(ircmsgs.join(self.channel, testnick, "user123!baz"))
self.irc.feedMsg(ircmsgs.part(self.channel, prefix="user123!baz"))
self.assertNotRegexp("seen %s" % testnick, "is in the channel right now")

def testSeenNoUser(self):
self.irc.feedMsg(ircmsgs.join(self.channel, self.irc.nick,
prefix=self.prefix))
Expand Down

0 comments on commit 0aec1ff

Please sign in to comment.