forked from bitshares/python-bitshares
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_account.py
More file actions
105 lines (92 loc) · 4.07 KB
/
Copy pathtest_account.py
File metadata and controls
105 lines (92 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import unittest
import mock
from pprint import pprint
from bitshares import BitShares
from bitshares.account import Account
from bitshares.amount import Amount
from bitshares.asset import Asset
from bitshares.instance import set_shared_bitshares_instance
from bitsharesbase.operationids import getOperationNameForId
from .fixtures import fixture_data, bitshares
class Testcases(unittest.TestCase):
def setUp(self):
fixture_data()
def test_account(self):
Account("init0")
Account("1.2.3")
account = Account("init0", full=True)
self.assertEqual(account.name, "init0")
self.assertEqual(account["name"], account.name)
self.assertEqual(account["id"], "1.2.100")
self.assertIsInstance(account.balance("1.3.0"), Amount)
# self.assertIsInstance(account.balance({"symbol": symbol}), Amount)
self.assertIsInstance(account.balances, list)
for h in account.history(limit=1):
pass
# BlockchainObjects method
account.cached = False
self.assertTrue(account.items())
account.cached = False
self.assertIn("id", account)
account.cached = False
self.assertEqual(account["id"], "1.2.90742")
self.assertEqual(str(account), "<Account 1.2.90742>")
self.assertIsInstance(Account(account), Account)
def test_account_upgrade(self):
account = Account("init0")
pprint(account)
tx = account.upgrade()
ops = tx["operations"]
op = ops[0][1]
self.assertEqual(len(ops), 1)
self.assertEqual(getOperationNameForId(ops[0][0]), "account_upgrade")
self.assertTrue(op["upgrade_to_lifetime_member"])
self.assertEqual(op["account_to_upgrade"], "1.2.100")
def test_openorders(self):
account = Account("init0")
self.assertIsInstance(account.openorders, list)
def test_calls(self):
account = Account("init0")
self.assertIsInstance(account.callpositions, dict)
def test_whitelist(self):
from bitsharesbase.operations import Account_whitelist
account = Account("init0")
tx = account.whitelist("committee-account")
self.assertEqual(len(tx["operations"]), 1)
self.assertEqual(tx["operations"][0][0], 7)
self.assertEqual(tx["operations"][0][1]["authorizing_account"], account["id"])
self.assertEqual(tx["operations"][0][1]["new_listing"], Account_whitelist.white_listed)
def test_blacklist(self):
from bitsharesbase.operations import Account_whitelist
account = Account("init0")
tx = account.blacklist("committee-account")
self.assertEqual(len(tx["operations"]), 1)
self.assertEqual(tx["operations"][0][0], 7)
self.assertEqual(tx["operations"][0][1]["authorizing_account"], account["id"])
self.assertEqual(tx["operations"][0][1]["new_listing"], Account_whitelist.black_listed)
def test_unlist(self):
from bitsharesbase.operations import Account_whitelist
account = Account("init0")
tx = account.nolist("committee-account")
self.assertEqual(len(tx["operations"]), 1)
self.assertEqual(tx["operations"][0][0], 7)
self.assertEqual(tx["operations"][0][1]["authorizing_account"], account["id"])
self.assertEqual(tx["operations"][0][1]["new_listing"], Account_whitelist.no_listing)
def test_accountupdate(self):
from bitshares.account import AccountUpdate
t = {'id': '2.6.29',
'lifetime_fees_paid': '44261516129',
'most_recent_op': '2.9.0',
'owner': '1.2.100',
'pending_fees': 0,
'pending_vested_fees': 16310,
'total_core_in_orders': '6788845277634',
'total_ops': 0}
update = AccountUpdate(t)
self.assertEqual(update["owner"], "1.2.100")
self.assertIsInstance(update.account, Account)
update.__repr__()
update = AccountUpdate("committee-account")
self.assertEqual(update["owner"], "1.2.0")
self.assertIsInstance(update.account, Account)
update.__repr__()