Add testing of units configuration

This commit is contained in:
James Vega 2004-03-26 00:57:14 +00:00
parent f130db33cc
commit 48d6dc5914

View File

@ -32,7 +32,7 @@
from testsupport import * from testsupport import *
if network: if network:
class WeatherTest(PluginTestCase, PluginDocumentation): class WeatherTest(PluginTestCase):
plugins = ('Weather',) plugins = ('Weather',)
def testHam(self): def testHam(self):
self.assertNotError('ham Columbus, OH') self.assertNotError('ham Columbus, OH')
@ -55,6 +55,21 @@ if network:
self.assertNotError('cnn Munich, de') self.assertNotError('cnn Munich, de')
self.assertNotError('cnn Tucson, AZ') self.assertNotError('cnn Tucson, AZ')
def testTemperatureUnit(self):
try:
orig = conf.supybot.plugins.Weather.temperatureUnit()
conf.supybot.plugins.Weather.temperatureUnit.setValue('F')
self.assertRegexp('cnn Columbus, OH', r'is -?\d+.F')
self.assertRegexp('ham Columbus, OH', r'is -?\d+.F')
conf.supybot.plugins.Weather.temperatureUnit.setValue('C')
self.assertRegexp('cnn Columbus, OH', r'is -?\d+.C')
self.assertRegexp('ham Columbus, OH', r'is -?\d+.C')
conf.supybot.plugins.Weather.temperatureUnit.setValue('K')
self.assertRegexp('cnn Columbus, OH', r'is -?\d+\.15\sK')
self.assertRegexp('ham Columbus, OH', r'is -?\d+\.15\sK')
finally:
conf.supybot.plugins.Weather.temperatureUnit.setValue(orig)
def testNoEscapingWebError(self): def testNoEscapingWebError(self):
self.assertNotRegexp('ham "buenos aires"', 'WebError') self.assertNotRegexp('ham "buenos aires"', 'WebError')