phenny-1/modules/test/test_tfw.py

50 lines
1.4 KiB
Python
Raw Normal View History

2012-05-31 03:39:40 -04:00
"""
test_tfw.py - tests for the fucking weather module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
"""
import re
import unittest
2012-06-05 00:42:56 -04:00
import tools
2012-05-31 03:39:40 -04:00
from mock import MagicMock, Mock
from modules.tfw import tfw
2012-05-31 03:39:40 -04:00
class TestTfw(unittest.TestCase):
def setUp(self):
self.phenny = MagicMock()
2012-06-05 00:42:56 -04:00
def test_badloc(self):
input = Mock(group=lambda x: 'tu3jgoajgoahghqog')
tfw(self.phenny, input)
self.phenny.say.assert_called_once_with(
"WHERE THE FUCK IS THAT? Try another location.")
2012-05-31 03:39:40 -04:00
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‽ .* \- .* \- [A-Z]{4} \d{2}:\d{2}Z$', out,
flags=re.UNICODE)
2012-05-31 03:39:40 -04:00
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‽ .* \- .* \- [A-Z]{4} \d{2}:\d{2}Z$', out,
flags=re.UNICODE)
2012-05-31 03:39:40 -04:00
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‽ .* \- .* \- [A-Z]{4} \d{2}:\d{2}Z$', out,
flags=re.UNICODE)
2012-05-31 03:39:40 -04:00
self.assertTrue(m)