forked from hirosystems/stacks.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unit_tests.py
93 lines (63 loc) · 2.41 KB
/
unit_tests.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Blockstack-client
~~~~~
copyright: (c) 2014 by Halfmoon Labs, Inc.
copyright: (c) 2015 by Blockstack.org
This file is part of Blockstack-client.
Blockstack-client is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Blockstack-client is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Blockstack-client. If not, see <http://www.gnu.org/licenses/>.
"""
import os
import sys
import json
import unittest
from blockstack_client import client
from blockstack_client.utils import print_result as pprint
from blockstack_client.config import BLOCKSTACKD_SERVER, BLOCKSTACKD_PORT, CONFIG_DIR
# start session
if not os.path.exists( CONFIG_DIR ):
os.makedirs( CONFIG_DIR )
client.session(server_host=BLOCKSTACKD_SERVER, server_port=BLOCKSTACKD_PORT)
test_names = ["muneeb.id", "fredwilson.id"]
class BlockstackClientTest(unittest.TestCase):
def tearDown(self):
pass
def test_ping(self):
""" Check ping
"""
resp = client.ping()
self.assertDictContainsSubset({'status': 'alive'}, resp)
def test_getinfo(self):
""" Check getinfo
"""
resp = client.getinfo()
if 'blocks' not in resp:
raise ValueError('blocks not in response')
self.assertIsInstance(resp, dict, msg="Not json")
def test_lookup(self):
""" Check lookup
"""
for fqu in test_names:
resp = client.get_name_blockchain_record(fqu)
if 'value_hash' not in resp:
raise ValueError('value_hash not in response')
self.assertIsInstance(resp, dict, msg="Not json")
def test_name_cost(self):
""" Check name cost
"""
resp = client.get_name_cost(test_names[0])
if 'satoshis' not in resp:
raise ValueError('satoshis not in response')
self.assertIsInstance(resp, dict, msg="Not json")
if __name__ == '__main__':
unittest.main()