def test_name(self): fiat = Fiat('EUR') self.assertEqual(fiat.name, 'EUR') fiat = Fiat('JPY') self.assertEqual(fiat.name, 'JPY') fiat = Fiat('USD') self.assertEqual(fiat.name, 'USD')
def test_frac_digits(self): fiat = Fiat('EUR') self.assertEqual(fiat.frac_digits, 2) fiat = Fiat('JPY') self.assertEqual(fiat.frac_digits, 0) fiat = Fiat('USD') self.assertEqual(fiat.frac_digits, 2)
def test_symbol(self): fiat = Fiat('EUR') self.assertEqual(fiat.symbol, '€') fiat = Fiat('JPY') self.assertEqual(fiat.symbol, '¥') fiat = Fiat('USD') self.assertEqual(fiat.symbol, '$')
def test_has_dot(self): fiat = Fiat('EUR') self.assertTrue(fiat.has_dot()) fiat = Fiat('JPY') self.assertFalse(fiat.has_dot()) fiat = Fiat('USD') self.assertTrue(fiat.has_dot())
def test_cent_to_dollar(self): fiat = Fiat('EUR') self.assertEqual(fiat.cent_to_dollar(100), Decimal('1')) self.assertEqual(fiat.cent_to_dollar(123), Decimal('1.23')) fiat = Fiat('JPY') self.assertEqual(fiat.cent_to_dollar(100), Decimal('100')) self.assertEqual(fiat.cent_to_dollar(123), Decimal('123')) fiat = Fiat('USD') self.assertEqual(fiat.cent_to_dollar(100), Decimal('1')) self.assertEqual(fiat.cent_to_dollar(123), Decimal('1.23'))
def test_format(self): from localize.fiat import Fiat locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') digit = Digit() fiat = Fiat('USD') self.assertEqual(digit.format(Decimal('1234.56'), fiat.frac_digits), '1,234.56') locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8') digit = Digit() fiat = Fiat('EUR') self.assertEqual(digit.format(Decimal('1234.56'), fiat.frac_digits), '1 234,56') locale.setlocale(locale.LC_ALL, 'ja_JP.UTF-8') digit = Digit() fiat = Fiat('JPY') self.assertEqual(digit.format(Decimal('123456'), fiat.frac_digits), '123,456')
def on_pre_enter(self, *args): super().on_pre_enter(*args) # language self.langs = Messenger.langs self.lang_spinner.text = self.app.app_config.get('app', 'lang') # fiat self.fiats = Fiat.get_fiat_list() self.fiat_spinner.text = self.app.app_config.get('app', 'fiat') # exchange self.exchanges = Exchange.get_exchange_list(self.app.fiat.name) self.exchange_spinner.text = self.app.exchange.name # readonly configs self.shop_name = self.app.app_config.get('app', 'shop_name') self.lnd_url = self.app.app_config.get('lnd', 'url') self.lnd_cert_path = self.app.app_config.get('lnd', 'cert_path') self.lnd_macaroon_path = self.app.app_config.get( 'lnd', 'macaroon_path')
def test_dollar_to_cent(self): fiat = Fiat('EUR') self.assertEqual(fiat.dollar_to_cent(Decimal('1.23')), 123) self.assertEqual(fiat.dollar_to_cent(Decimal('1.234')), 123) fiat = Fiat('JPY') self.assertEqual(fiat.dollar_to_cent(Decimal('123')), 123) fiat = Fiat('USD') self.assertEqual(fiat.dollar_to_cent(Decimal('1.23')), 123) self.assertEqual(fiat.dollar_to_cent(Decimal('1.234')), 123)
def build(self): self.messenger = Messenger(self.app_config.get('app', 'lang')) self.fiat = Fiat(self.app_config.get('app', 'fiat')) self.digit = Digit()