From 6979d538d62d99f9bb6f8d142dea8c46234f2722 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Sat, 2 Jun 2012 03:08:29 -0700 Subject: [PATCH] add weather tests --- modules/test/test_weather.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 modules/test/test_weather.py diff --git a/modules/test/test_weather.py b/modules/test/test_weather.py new file mode 100644 index 0000000..5238387 --- /dev/null +++ b/modules/test/test_weather.py @@ -0,0 +1,35 @@ +""" +test_weather.py - tests for the weather module +author: mutantmonkey +""" + +import re +import unittest +from mock import MagicMock, Mock, patch +from modules.weather import location, local, code, f_weather + + +class TestWeather(unittest.TestCase): + def setUp(self): + self.phenny = MagicMock() + + def test_location(self): + name, countryName, lat, lng = location('24060') + + self.assertEqual(name, "Blacksburg") + self.assertEqual(countryName, "United States") + self.assertEqual(lat, 37.2295733) + self.assertEqual(lng, -80.4139393) + + def test_code(self): + icao = code(self.phenny, '20164') + + self.assertEqual(icao, 'KIAD') + + def test_location(self): + input = Mock( + match=Mock(group=lambda x: 'KIAD'), + sender='#phenny', nick='phenny_test') + f_weather(self.phenny, input) + + assert self.phenny.msg.called is True