bitcoin: uppercase currencies for api
parent
d7654c65d1
commit
2e995476ee
|
@ -20,15 +20,16 @@ def bitcoin(phenny, input):
|
||||||
"like .bitcoin 1 EUR")
|
"like .bitcoin 1 EUR")
|
||||||
return
|
return
|
||||||
|
|
||||||
if currency == 'BTC':
|
if currency.upper() == 'BTC':
|
||||||
from_btc = True
|
from_btc = True
|
||||||
currency = input.group(4)
|
currency = input.group(4)
|
||||||
else:
|
else:
|
||||||
from_btc = False
|
from_btc = False
|
||||||
|
currency = currency.upper()
|
||||||
|
|
||||||
if not currency:
|
if not currency:
|
||||||
currency = 'USD'
|
currency = 'USD'
|
||||||
currency = currency.strip()[:3]
|
currency = currency.strip()[:3].upper()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
amount = decimal.Decimal(amount)
|
amount = decimal.Decimal(amount)
|
||||||
|
|
|
@ -83,3 +83,10 @@ class TestCalc(unittest.TestCase):
|
||||||
|
|
||||||
out = self.phenny.say.call_args[0][0]
|
out = self.phenny.say.call_args[0][0]
|
||||||
self.assertNotRegex(out, r'[\d\.]+ BTC')
|
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')
|
||||||
|
|
Loading…
Reference in New Issue