tfw: tests and retry on first failure
This commit is contained in:
47
modules/test/test_tfw.py
Normal file
47
modules/test/test_tfw.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
test_tfw.py - tests for the fucking weather module
|
||||
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
|
||||
"""
|
||||
|
||||
# add current working directory to path
|
||||
import sys
|
||||
sys.path.append('.')
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from mock import MagicMock, Mock
|
||||
from modules.tfw import tfw
|
||||
|
||||
class TestTfw(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.phenny = MagicMock()
|
||||
|
||||
#def test_badloc(self):
|
||||
# input = Mock(group=lambda x: 'tu3jgoajgoahghqog')
|
||||
# tfw(self.phenny, input)
|
||||
#
|
||||
# self.phenny.say.assert_called_once_with("UNKNOWN FUCKING LOCATION. Try another?")
|
||||
|
||||
def test_celsius(self):
|
||||
input = Mock(group=lambda x: '24060')
|
||||
tfw(self.phenny, input, celsius=True)
|
||||
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^\d+°C‽ .* \- .*$', out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
|
||||
def test_fahrenheit(self):
|
||||
input = Mock(group=lambda x: '24060')
|
||||
tfw(self.phenny, input, fahrenheit=True)
|
||||
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^\d+°F‽ .* \- .*$', out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
|
||||
def test_mev(self):
|
||||
input = Mock(group=lambda x: '24060')
|
||||
tfw(self.phenny, input)
|
||||
|
||||
out = self.phenny.say.call_args[0][0]
|
||||
m = re.match('^[\d\.]+ meV‽ .* \- .*$', out, flags=re.UNICODE)
|
||||
self.assertTrue(m)
|
||||
Reference in New Issue
Block a user