tfw: fix "sexy time" for 69°F

This commit is contained in:
mutantmonkey
2013-09-30 22:40:03 -07:00
parent b8dde03000
commit 4edf618ef2
2 changed files with 47 additions and 25 deletions

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
"""
test_tfw.py - tests for the fucking weather module
author: mutantmonkey <mutantmonkey@mutantmonkey.in>
@@ -7,7 +8,7 @@ import re
import unittest
import tools
from mock import MagicMock, Mock
from modules.tfw import tfw
from modules import tfw
class TestTfw(unittest.TestCase):
@@ -16,34 +17,47 @@ class TestTfw(unittest.TestCase):
def test_badloc(self):
input = Mock(group=lambda x: 'tu3jgoajgoahghqog')
tfw(self.phenny, input)
tfw.tfw(self.phenny, input)
self.phenny.say.assert_called_once_with(
"WHERE THE FUCK IS THAT? Try another location.")
"WHERE THE FUCK IS THAT? Try another location.")
def test_celsius(self):
input = Mock(group=lambda x: '24060')
tfw(self.phenny, input, celsius=True)
tfw.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)
flags=re.UNICODE)
self.assertTrue(m)
def test_fahrenheit(self):
input = Mock(group=lambda x: '24060')
tfw(self.phenny, input, fahrenheit=True)
tfw.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)
flags=re.UNICODE)
self.assertTrue(m)
def test_mev(self):
input = Mock(group=lambda x: '24060')
tfw(self.phenny, input)
tfw.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)
flags=re.UNICODE)
self.assertTrue(m)
def test_sexy_time(self):
input = Mock(group=lambda x: 'KBCB')
tfw.web = MagicMock()
tfw.metar.parse = lambda x: Mock(temperature=21)
tfw.tfwf(self.phenny, input)
out = self.phenny.say.call_args[0][0]
m = re.match(
r'^69°F‽ IT\'S FUCKING SEXY TIME \- .*',
out,
flags=re.UNICODE)
self.assertTrue(m)