add unit tests for remind module
parent
065fa5949e
commit
e94ca0d74a
|
@ -56,6 +56,7 @@ def setup(phenny):
|
|||
|
||||
targs = (phenny,)
|
||||
t = threading.Thread(target=monitor, args=targs)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
scaling = {
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
"""
|
||||
test_remind.py - tests for the remind module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
import re
|
||||
import unittest
|
||||
import threading
|
||||
import time
|
||||
import tools
|
||||
from mock import MagicMock, Mock, patch
|
||||
from modules import remind
|
||||
|
||||
|
||||
class TestRemind(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.phenny = MagicMock()
|
||||
self.phenny.nick = 'phenny'
|
||||
self.phenny.config.host = 'test-phenny.example.com'
|
||||
|
||||
remind.load_database = lambda name: {}
|
||||
remind.dump_database = lambda name, data: name
|
||||
remind.setup(self.phenny)
|
||||
|
||||
def test_remind(self):
|
||||
secs = 5
|
||||
input = Mock(sender='#testsworth', nick='Testsworth',
|
||||
bytes='.in {0} seconds TEST REMIND'.format(secs))
|
||||
|
||||
remind.remind(self.phenny, input)
|
||||
self.phenny.reply.assert_called_once_with("Okay, will remind in {0}"\
|
||||
" secs".format(secs))
|
||||
|
||||
time.sleep(secs + 1)
|
||||
self.phenny.msg.assert_called_once_with(input.sender,
|
||||
input.nick + ': TEST REMIND')
|
||||
|
||||
def test_remind_nomsg(self):
|
||||
secs = 5
|
||||
input = Mock(sender='#testsworth', nick='Testsworth',
|
||||
bytes='.in {0} seconds'.format(secs))
|
||||
|
||||
remind.remind(self.phenny, input)
|
||||
self.phenny.reply.assert_called_once_with("Okay, will remind in {0}"\
|
||||
" secs".format(secs))
|
||||
|
||||
time.sleep(secs + 1)
|
||||
self.phenny.msg.assert_called_once_with(input.sender,
|
||||
input.nick + '!')
|
Loading…
Reference in New Issue