Beispiel #1
0
 def test_save_fiat_and_reset(self):
     self.assertEqual(False, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1000.01', self.fx, self.value_sat))
     saved = self.fiat_value[ccy][txid]
     self.assertEqual('1,000.01', self.fx.ccy_amount_str(Decimal(saved), commas=True))
     self.assertEqual(True,       Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx, self.value_sat))
     self.assertNotIn(txid, self.fiat_value[ccy])
     # even though we are not setting it to the exact fiat value according to the exchange rate, precision is truncated away
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.002', self.fx, self.value_sat))
Beispiel #2
0
 def test_save_fiat_and_reset(self):
     self.assertEqual(False, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1000.01', self.fx, self.value_sat))
     saved = self.fiat_value[ccy][txid]
     self.assertEqual('1,000.01', self.fx.ccy_amount_str(Decimal(saved), commas=True))
     self.assertEqual(True,       Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx, self.value_sat))
     self.assertNotIn(txid, self.fiat_value[ccy])
     # even though we are not setting it to the exact fiat value according to the exchange rate, precision is truncated away
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.002', self.fx, self.value_sat))
Beispiel #3
0
 def setUp(self):
     self.value_sat = COIN
     self.fiat_value = {}
     self.wallet = FakeWallet(fiat_value=self.fiat_value)
     self.fx = FakeFxThread(FakeExchange(Decimal('1000.001')))
     default_fiat = Abstract_Wallet.default_fiat_value(self.wallet, txid, self.fx, self.value_sat)
     self.assertEqual(Decimal('1000.001'), default_fiat)
     self.assertEqual('1,000.00', self.fx.ccy_amount_str(default_fiat, commas=True))
Beispiel #4
0
 def setUp(self):
     super().setUp()
     self.value_sat = COIN
     self.fiat_value = {}
     self.wallet = FakeWallet(fiat_value=self.fiat_value)
     self.fx = FakeFxThread(FakeExchange(Decimal('1000.001')))
     default_fiat = Abstract_Wallet.default_fiat_value(self.wallet, txid, self.fx, self.value_sat)
     self.assertEqual(Decimal('1000.001'), default_fiat)
     self.assertEqual('1,000.00', self.fx.ccy_amount_str(default_fiat, commas=True))
Beispiel #5
0
 def test_save_garbage(self):
     self.assertEqual(False, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, 'garbage', self.fx, self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Beispiel #6
0
 def test_empty_resets(self):
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx, self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Beispiel #7
0
 def test_too_high_precision_value_resets_with_no_saved_value(self):
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.001', self.fx, self.value_sat))
Beispiel #8
0
 def test_save_garbage(self):
     self.assertEqual(False, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, 'garbage', self.fx, self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Beispiel #9
0
 def test_empty_resets(self):
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '', self.fx, self.value_sat))
     self.assertNotIn(ccy, self.fiat_value)
Beispiel #10
0
 def test_too_high_precision_value_resets_with_no_saved_value(self):
     self.assertEqual(True, Abstract_Wallet.set_fiat_value(self.wallet, txid, ccy, '1,000.001', self.fx, self.value_sat))