Add tests.

This commit is contained in:
Pedro de Oliveira 2020-05-03 21:56:50 +01:00
parent 00425b5282
commit 675441cce5
4 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,5 @@
###
# Copyright (c) 2019, Pedro de Oliveira
# Copyright (c) 2020, Pedro de Oliveira
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
###
# Copyright (c) 2019, Pedro de Oliveira
# Copyright (c) 2020, Pedro de Oliveira
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -62,6 +62,8 @@ class Anav(callbacks.Plugin):
re.sub(r'\s+', ' ', anavnet.get_message(position)['descricao'].replace('\n',' ')).strip())
except Exception as e:
message = "NOP: {}".format(e)
irc.error(message, prefixNick=False)
return
irc.reply(message, prefixNick=False)
latest = wrap(latest, ['int', optional('int', default=1)])

1
Anav/requirements.txt Normal file
View File

@ -0,0 +1 @@
anavnet

View File

@ -1,5 +1,5 @@
###
# Copyright (c) 2019, Pedro de Oliveira
# Copyright (c) 2020, Pedro de Oliveira
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -34,5 +34,19 @@ from supybot.test import *
class AnavTestCase(PluginTestCase):
plugins = ('Anav',)
def testPorts(self):
self.assertNotError('anav ports')
self.assertRegexp('anav ports', r'\d: .*,')
self.assertRegexp('anav ports', '16: Lisboa')
self.assertHelp('anav ports --help')
def testLatest(self):
self.assertHelp('anav latest')
self.assertError('anav latest 666')
self.assertError('anav latest -1')
self.assertError('anav latest 16 -1')
self.assertError('anav latest 16 666')
self.assertRegexp('anav latest 16', 'Lisboa')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: