This commit is contained in:
Jack 2016-07-28 16:27:16 -04:00
parent 419aa1d78f
commit 2e3342d20d
3 changed files with 42 additions and 44 deletions

View file

@ -147,10 +147,8 @@ class ExchangeRateManager(object):
def to_lbc(self, fee):
if fee is None:
return None
if not isinstance(fee, LBRYFeeValidator):
fee_in = LBRYFeeValidator(fee)
else:
fee_in = fee
fee_in = LBRYFeeValidator(fee)
return LBRYFeeValidator({fee_in.currency_symbol:
{
@ -202,10 +200,8 @@ class DummyExchangeRateManager(object):
def to_lbc(self, fee):
if fee is None:
return None
if not isinstance(fee, LBRYFeeValidator):
fee_in = LBRYFeeValidator(fee)
else:
fee_in = fee
fee_in = LBRYFeeValidator(fee)
return LBRYFeeValidator({fee_in.currency_symbol:
{

View file

@ -0,0 +1,38 @@
import mock
from lbrynet.core import LBRYMetadata
from lbrynet.lbrynet_daemon import LBRYExchangeRateManager
from twisted.trial import unittest
class LBRYFeeFormatTest(unittest.TestCase):
def test_fee_created_with_correct_inputs(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
fee = LBRYMetadata.LBRYFeeValidator(fee_dict)
self.assertEqual(10.0, fee['USD']['amount'])
class LBRYFeeTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch('time.time')
self.time = self.patcher.start()
self.time.return_value = 0
def tearDown(self):
self.time.stop()
def test_fee_converts_to_lbc(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
rates = {'BTCLBC': {'spot': 3.0, 'ts': 2}, 'USDBTC': {'spot': 2.0, 'ts': 3}}
manager = LBRYExchangeRateManager.DummyExchangeRateManager(rates)
self.assertEqual(60.0, manager.to_lbc(fee_dict).amount)

View file

@ -1,43 +1,7 @@
import mock
from lbrynet.core import LBRYMetadata
from lbrynet.lbrynet_daemon import LBRYExchangeRateManager
from twisted.trial import unittest
class LBRYFeeFormatTest(unittest.TestCase):
def test_fee_created_with_correct_inputs(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
fee = LBRYMetadata.LBRYFeeValidator(fee_dict)
self.assertEqual(10.0, fee['USD']['amount'])
class LBRYFeeTest(unittest.TestCase):
def setUp(self):
self.patcher = mock.patch('time.time')
self.time = self.patcher.start()
self.time.return_value = 0
def tearDown(self):
self.time.stop()
def test_fee_converts_to_lbc(self):
fee_dict = {
'USD': {
'amount': 10.0,
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
}
}
rates = {'BTCLBC': {'spot': 3.0, 'ts': 2}, 'USDBTC': {'spot': 2.0, 'ts': 3}}
manager = LBRYExchangeRateManager.DummyExchangeRateManager(rates)
self.assertEqual(60.0, manager.to_lbc(fee_dict).amount)
class MetadataTest(unittest.TestCase):
def test_assertion_if_source_is_missing(self):
metadata = {}