tfw: fix "sexy time" for 69°F
parent
b8dde03000
commit
4edf618ef2
|
@ -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,14 +17,14 @@ 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.")
|
||||
|
||||
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,
|
||||
|
@ -32,7 +33,7 @@ class TestTfw(unittest.TestCase):
|
|||
|
||||
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,
|
||||
|
@ -41,9 +42,22 @@ class TestTfw(unittest.TestCase):
|
|||
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -11,6 +11,7 @@ import random
|
|||
import metar
|
||||
import web
|
||||
|
||||
|
||||
def tfw(phenny, input, fahrenheit=False, celsius=False):
|
||||
""".tfw <city/zip> - Show the fucking weather at the specified location."""
|
||||
|
||||
|
@ -52,7 +53,8 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
|||
|
||||
if w.temperature < 6:
|
||||
remark = "IT'S FUCKING COLD"
|
||||
flavors = ["Where's the cat? Oh shit. Fluffy's frozen.",
|
||||
flavors = [
|
||||
"Where's the cat? Oh shit. Fluffy's frozen.",
|
||||
"Nothing a few shots couldn't fix",
|
||||
"Should have gone south",
|
||||
"You think this is cold? Have you been to upstate New York?",
|
||||
|
@ -85,7 +87,8 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
|||
"It's bone chilling cold out. Sorry ladies."]
|
||||
elif w.temperature < 20:
|
||||
remark = "IT'S FUCKING...ALRIGHT"
|
||||
flavors = ["Might as well rain, I'm not going out in that.",
|
||||
flavors = [
|
||||
"Might as well rain, I'm not going out in that.",
|
||||
"Better than a sharp stick in the eye.",
|
||||
"Everything's nice butter weather!",
|
||||
"At least you aren't living in a small town in Alaska",
|
||||
|
@ -114,7 +117,8 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
|||
"Maybe Jersey Shore is on tonight."]
|
||||
else:
|
||||
remark = "IT'S FUCKING NICE"
|
||||
flavors = ["I made today breakfast in bed.", "FUCKING SWEET",
|
||||
flavors = [
|
||||
"I made today breakfast in bed.", "FUCKING SWEET",
|
||||
"Quit your bitching", "Enjoy.", "IT'S ABOUT FUCKING TIME",
|
||||
"READ A FUCKIN' BOOK", "LETS HAVE A FUCKING PICNIC",
|
||||
"It is safe to take your ball-mittens off.", "More please.",
|
||||
|
@ -147,9 +151,10 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
|||
elif w.precipitation in ("hail", "small hail"):
|
||||
remark += " AND HAILING"
|
||||
|
||||
if tempf == 69:
|
||||
if int(tempf) == 69:
|
||||
remark = "IT'S FUCKING SEXY TIME"
|
||||
flavors = ["Why is 77 better than 69? You get eight more.",
|
||||
flavors = [
|
||||
"Why is 77 better than 69? You get eight more.",
|
||||
"What comes after 69? Mouthwash.",
|
||||
"If you are given two contradictory orders, obey them both.",
|
||||
"a good fuckin' time! ;)",
|
||||
|
@ -163,15 +168,18 @@ def tfw(phenny, input, fahrenheit=False, celsius=False):
|
|||
phenny.say(response)
|
||||
tfw.rule = (['tfw'], r'(.*)')
|
||||
|
||||
|
||||
def tfwf(phenny, input):
|
||||
""".tfwf <city/zip> - The fucking weather, in fucking degrees Fahrenheit."""
|
||||
return tfw(phenny, input, fahrenheit=True)
|
||||
tfwf.rule = (['tfwf'], r'(.*)')
|
||||
|
||||
|
||||
def tfwc(phenny, input):
|
||||
""".tfwc <city/zip> - The fucking weather, in fucking degrees celsius."""
|
||||
return tfw(phenny, input, celsius=True)
|
||||
tfwc.rule = (['tfwc'], r'(.*)')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(__doc__.strip())
|
||||
|
|
Loading…
Reference in New Issue