bitcoin: uppercase currencies for api

master
mutantmonkey 2013-10-25 18:53:21 -07:00
parent d7654c65d1
commit 2e995476ee
2 changed files with 10 additions and 2 deletions

View File

@ -20,15 +20,16 @@ def bitcoin(phenny, input):
"like .bitcoin 1 EUR")
return
if currency == 'BTC':
if currency.upper() == 'BTC':
from_btc = True
currency = input.group(4)
else:
from_btc = False
currency = currency.upper()
if not currency:
currency = 'USD'
currency = currency.strip()[:3]
currency = currency.strip()[:3].upper()
try:
amount = decimal.Decimal(amount)

View File

@ -83,3 +83,10 @@ class TestCalc(unittest.TestCase):
out = self.phenny.say.call_args[0][0]
self.assertNotRegex(out, r'[\d\.]+ BTC')
def test_lettercase(self):
input = Mock(group=self.makegroup('1', 'btc', 'EuR'))
bitcoin(self.phenny, input)
out = self.phenny.say.call_args[0][0]
self.assertRegex(out, r'\d+\.\d{2} EUR')