From 2e995476ee1f7afe016773298810ee1f4b38fcd4 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Fri, 25 Oct 2013 18:53:21 -0700 Subject: [PATCH] bitcoin: uppercase currencies for api --- modules/bitcoin.py | 5 +++-- modules/test/test_bitcoin.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/bitcoin.py b/modules/bitcoin.py index 524965c..69a397d 100644 --- a/modules/bitcoin.py +++ b/modules/bitcoin.py @@ -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) diff --git a/modules/test/test_bitcoin.py b/modules/test/test_bitcoin.py index d4f7d2b..9d87b3a 100644 --- a/modules/test/test_bitcoin.py +++ b/modules/test/test_bitcoin.py @@ -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')