forked from LBRYCommunity/lbry-sdk
use assertFailure, move around assertEqual arguments to standard locations
This commit is contained in:
parent
c278972f26
commit
fe4ea9b33a
1 changed files with 18 additions and 24 deletions
|
@ -31,12 +31,6 @@ class MocLbryumWallet(Wallet):
|
|||
|
||||
class WalletTest(unittest.TestCase):
|
||||
|
||||
def _check_exception(self, d):
|
||||
def check(err):
|
||||
with self.assertRaises(Exception):
|
||||
err.raiseException()
|
||||
d.addCallbacks(lambda _: self.assertTrue(False), lambda err: check(err))
|
||||
|
||||
def test_failed_send_name_claim(self):
|
||||
def not_enough_funds_send_name_claim(self, name, val, amount):
|
||||
claim_out = {'success':False, 'reason':'Not enough funds'}
|
||||
|
@ -44,11 +38,11 @@ class WalletTest(unittest.TestCase):
|
|||
MocLbryumWallet._send_name_claim = not_enough_funds_send_name_claim
|
||||
wallet = MocLbryumWallet()
|
||||
d = wallet.claim_name('test', 1, test_metadata)
|
||||
self._check_exception(d)
|
||||
self.assertFailure(d,Exception)
|
||||
return d
|
||||
|
||||
def test_successful_send_name_claim(self):
|
||||
test_claim_out = {
|
||||
expected_claim_out = {
|
||||
"claimid": "f43dc06256a69988bdbea09a58c80493ba15dcfa",
|
||||
"fee": "0.00012",
|
||||
"nout": 0,
|
||||
|
@ -58,13 +52,13 @@ class WalletTest(unittest.TestCase):
|
|||
|
||||
def check_out(claim_out):
|
||||
self.assertTrue('success' not in claim_out)
|
||||
self.assertEqual(claim_out['claimid'], test_claim_out['claimid'])
|
||||
self.assertEqual(claim_out['fee'], test_claim_out['fee'])
|
||||
self.assertEqual(claim_out['nout'], test_claim_out['nout'])
|
||||
self.assertEqual(claim_out['txid'], test_claim_out['txid'])
|
||||
self.assertEqual(expected_claim_out['claimid'], claim_out['claimid'])
|
||||
self.assertEqual(expected_claim_out['fee'], claim_out['fee'])
|
||||
self.assertEqual(expected_claim_out['nout'], claim_out['nout'])
|
||||
self.assertEqual(expected_claim_out['txid'], claim_out['txid'])
|
||||
|
||||
def success_send_name_claim(self, name, val, amount):
|
||||
return test_claim_out
|
||||
return expected_claim_out
|
||||
|
||||
MocLbryumWallet._send_name_claim = success_send_name_claim
|
||||
wallet = MocLbryumWallet()
|
||||
|
@ -79,11 +73,11 @@ class WalletTest(unittest.TestCase):
|
|||
MocLbryumWallet._support_claim = failed_support_claim
|
||||
wallet = MocLbryumWallet()
|
||||
d = wallet.support_claim('test', "f43dc06256a69988bdbea09a58c80493ba15dcfa", 1)
|
||||
self._check_exception(d)
|
||||
self.assertFailure(d,Exception)
|
||||
return d
|
||||
|
||||
def test_succesful_support(self):
|
||||
test_support_out = {
|
||||
expected_support_out = {
|
||||
"fee": "0.000129",
|
||||
"nout": 0,
|
||||
"success": True,
|
||||
|
@ -92,12 +86,12 @@ class WalletTest(unittest.TestCase):
|
|||
|
||||
def check_out(claim_out):
|
||||
self.assertTrue('success' not in claim_out)
|
||||
self.assertEqual(claim_out['fee'], test_support_out['fee'])
|
||||
self.assertEqual(claim_out['nout'], test_support_out['nout'])
|
||||
self.assertEqual(claim_out['txid'], test_support_out['txid'])
|
||||
self.assertEqual(expected_support_out['fee'], claim_out['fee'])
|
||||
self.assertEqual(expected_support_out['nout'], claim_out['nout'])
|
||||
self.assertEqual(expected_support_out['txid'], claim_out['txid'])
|
||||
|
||||
def success_support_claim(self, name, val, amount):
|
||||
return threads.deferToThread(lambda: test_support_out)
|
||||
return threads.deferToThread(lambda: expected_support_out)
|
||||
MocLbryumWallet._support_claim = success_support_claim
|
||||
wallet = MocLbryumWallet()
|
||||
d = wallet.support_claim('test', "f43dc06256a69988bdbea09a58c80493ba15dcfa", 1)
|
||||
|
@ -111,11 +105,11 @@ class WalletTest(unittest.TestCase):
|
|||
MocLbryumWallet._abandon_claim = failed_abandon_claim
|
||||
wallet = MocLbryumWallet()
|
||||
d = wallet.abandon_claim("11030a76521e5f552ca87ad70765d0cc52e6ea4c0dc0063335e6cf2a9a85085f", 1)
|
||||
self._check_exception(d)
|
||||
self.assertFailure(d,Exception)
|
||||
return d
|
||||
|
||||
def test_successful_abandon(self):
|
||||
test_abandon_out = {
|
||||
expected_abandon_out = {
|
||||
"fee": "0.000096",
|
||||
"success": True,
|
||||
"txid": "0578c161ad8d36a7580c557d7444f967ea7f988e194c20d0e3c42c3cabf110dd"
|
||||
|
@ -123,11 +117,11 @@ class WalletTest(unittest.TestCase):
|
|||
|
||||
def check_out(claim_out):
|
||||
self.assertTrue('success' not in claim_out)
|
||||
self.assertEqual(claim_out['fee'], test_abandon_out['fee'])
|
||||
self.assertEqual(claim_out['txid'], test_abandon_out['txid'])
|
||||
self.assertEqual(expected_abandon_out['fee'], claim_out['fee'])
|
||||
self.assertEqual(expected_abandon_out['txid'], claim_out['txid'])
|
||||
|
||||
def success_abandon_claim(self, claim_outpoint):
|
||||
return threads.deferToThread(lambda: test_abandon_out)
|
||||
return threads.deferToThread(lambda: expected_abandon_out)
|
||||
|
||||
MocLbryumWallet._abandon_claim = success_abandon_claim
|
||||
wallet = MocLbryumWallet()
|
||||
|
|
Loading…
Reference in a new issue