From 0dd6193eaa549cc632180909b3f8eb649dd8d0cf Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 4 Aug 2018 21:04:08 -0400 Subject: [PATCH] FakeComponent was missing __lt__ comparison operator and couldnt be put in set() --- lbrynet/daemon/Daemon.py | 6 +----- tests/mocks.py | 3 +++ tests/unit/lbrynet_daemon/test_Daemon.py | 8 ++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index c16a352a5..b69bd7d88 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -221,7 +221,7 @@ class Daemon(AuthJSONRPCServer): # TODO: delete these, get the components where needed self.storage = None self.dht_node = None - #self.wallet = None + self.wallet = None self.sd_identifier = None self.file_manager = None self.exchange_rate_manager = None @@ -237,10 +237,6 @@ class Daemon(AuthJSONRPCServer): def ledger(self): return self.wallet.default_account.ledger - @property - def wallet(self): - return self.session.wallet - @defer.inlineCallbacks def setup(self): log.info("Starting lbrynet-daemon") diff --git a/tests/mocks.py b/tests/mocks.py index 7a312350f..4e3321768 100644 --- a/tests/mocks.py +++ b/tests/mocks.py @@ -400,6 +400,9 @@ class FakeComponent(object): self._running = False defer.returnValue(result) + def __lt__(self, other): + return self.component_name < other.component_name + class FakeDelayedWallet(FakeComponent): component_name = "wallet" diff --git a/tests/unit/lbrynet_daemon/test_Daemon.py b/tests/unit/lbrynet_daemon/test_Daemon.py index 4b74048e0..ed8fb2d8b 100644 --- a/tests/unit/lbrynet_daemon/test_Daemon.py +++ b/tests/unit/lbrynet_daemon/test_Daemon.py @@ -50,8 +50,8 @@ def get_test_daemon(data_rate=None, generous=True, with_fee=False): ) daemon = LBRYDaemon(component_manager=component_manager) daemon.payment_rate_manager = OnlyFreePaymentsManager() - daemon.wallet = mock.Mock(spec=Wallet.LBRYumWallet) - daemon.wallet.wallet = mock.Mock(spec=NewWallet) + daemon.wallet = mock.Mock(spec=LbryWalletManager) + daemon.wallet.wallet = mock.Mock(spec=Wallet) daemon.wallet.wallet.use_encryption = False daemon.wallet.network = FakeNetwork() daemon.storage = mock.Mock(spec=SQLiteStorage) @@ -106,7 +106,7 @@ class TestCostEst(unittest.TestCase): correct_result = size / 10 ** 6 * data_rate + fake_fee_amount daemon = get_test_daemon(generous=False, with_fee=True) result = yield daemon.get_est_cost("test", size) - self.assertEqual(result, correct_result) + self.assertEqual(result, round(correct_result, 1)) @defer.inlineCallbacks def test_generous_data_and_no_fee(self): @@ -123,7 +123,7 @@ class TestCostEst(unittest.TestCase): correct_result = size / 10 ** 6 * data_rate daemon = get_test_daemon(generous=False) result = yield daemon.get_est_cost("test", size) - self.assertEqual(result, correct_result) + self.assertEqual(result, round(correct_result, 1)) class TestJsonRpc(unittest.TestCase):