Skip to content

Commit c123d9b

Browse files
committed
Version 0.14
- Handle websockets - Write BlockId object in documents
2 parents 6f9d7fa + f990f34 commit c123d9b

21 files changed

+207
-134
lines changed

_ucoinpy_test/api/bma/test_blockchain.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def test_parameters(self):
2727
jsonschema.validate(json_sample, Parameters.schema)
2828

2929
def test_parameters_bad(self):
30-
async def handler(request):
30+
async def handler(request):
3131
await request.read()
3232
return web.Response(body=b'{}', content_type='application/json')
3333

34-
async def go():
34+
async def go():
3535
_, srv, url = await self.create_server('GET', '/', handler)
3636
params = Parameters(None)
37-
params.reverse_url = lambda path: url
37+
params.reverse_url = lambda scheme, path: url
3838
with self.assertRaises(jsonschema.exceptions.ValidationError):
3939
await params.get()
4040

@@ -95,28 +95,28 @@ def test_schema_block_0(self):
9595
jsonschema.validate(json_sample, Current.schema)
9696

9797
def test_block_bad(self):
98-
async def handler(request):
98+
async def handler(request):
9999
await request.read()
100100
return web.Response(body=b'{}', content_type='application/json')
101101

102-
async def go():
102+
async def go():
103103
_, srv, url = await self.create_server('GET', '/100', handler)
104104
block = Block(None, 100)
105-
block.reverse_url = lambda path: url
105+
block.reverse_url = lambda scheme, path: url
106106
with self.assertRaises(jsonschema.exceptions.ValidationError):
107107
await block.get()
108108

109109
self.loop.run_until_complete(go())
110110

111111
def test_current_bad(self):
112-
async def handler(request):
112+
async def handler(request):
113113
await request.read()
114114
return web.Response(body=b'{}', content_type='application/json')
115115

116-
async def go():
116+
async def go():
117117
_, srv, url = await self.create_server('GET', '/', handler)
118118
current = Current(None)
119-
current.reverse_url = lambda path: url
119+
current.reverse_url = lambda scheme, path: url
120120
with self.assertRaises(jsonschema.exceptions.ValidationError):
121121
await current.get()
122122

@@ -169,14 +169,14 @@ def test_schema_hardship(self):
169169
jsonschema.validate(json_sample, Hardship.schema)
170170

171171
def test_hardship_bad(self):
172-
async def handler(request):
172+
async def handler(request):
173173
await request.read()
174174
return web.Response(body=b'{}', content_type='application/json')
175175

176-
async def go():
176+
async def go():
177177
_, srv, url = await self.create_server('GET', '/fingerprint', handler)
178178
hardship = Hardship(None, "fingerprint")
179-
hardship.reverse_url = lambda path: url
179+
hardship.reverse_url = lambda scheme, path: url
180180
with self.assertRaises(jsonschema.exceptions.ValidationError):
181181
await hardship.get()
182182

@@ -207,14 +207,14 @@ def test_schema_membership(self):
207207
jsonschema.validate(json_sample, Membership.schema)
208208

209209
def test_membership_bad(self):
210-
async def handler(request):
210+
async def handler(request):
211211
await request.read()
212212
return web.Response(body=b'{}', content_type='application/json')
213213

214-
async def go():
214+
async def go():
215215
_, srv, url = await self.create_server('GET', '/pubkey', handler)
216216
membership = Membership(None, "pubkey")
217-
membership.reverse_url = lambda path: url
217+
membership.reverse_url = lambda scheme, path: url
218218
with self.assertRaises(jsonschema.exceptions.ValidationError):
219219
await membership.get()
220220

@@ -229,14 +229,14 @@ def test_schema_newcomers(self):
229229
jsonschema.validate(json_sample, Newcomers.schema)
230230

231231
def test_newcomers_bad(self):
232-
async def handler(request):
232+
async def handler(request):
233233
await request.read()
234234
return web.Response(body=b'{}', content_type='application/json')
235235

236-
async def go():
236+
async def go():
237237
_, srv, url = await self.create_server('GET', '/', handler)
238238
newcomers = Newcomers(None)
239-
newcomers.reverse_url = lambda path: url
239+
newcomers.reverse_url = lambda scheme, path: url
240240
with self.assertRaises(jsonschema.exceptions.ValidationError):
241241
await newcomers.get()
242242

@@ -251,14 +251,14 @@ def test_schema_certifications(self):
251251
jsonschema.validate(json_sample, Certifications.schema)
252252

253253
def test_certifications_bad(self):
254-
async def handler(request):
254+
async def handler(request):
255255
await request.read()
256256
return web.Response(body=b'{}', content_type='application/json')
257257

258-
async def go():
258+
async def go():
259259
_, srv, url = await self.create_server('GET', '/', handler)
260260
certs = Certifications(None)
261-
certs.reverse_url = lambda path: url
261+
certs.reverse_url = lambda scheme, path: url
262262
with self.assertRaises(jsonschema.exceptions.ValidationError):
263263
await certs.get()
264264

@@ -273,14 +273,14 @@ def test_schema_joiners(self):
273273
jsonschema.validate(json_sample, Joiners.schema)
274274

275275
def test_joiners_bad(self):
276-
async def handler(request):
276+
async def handler(request):
277277
await request.read()
278278
return web.Response(body=b'{}', content_type='application/json')
279279

280-
async def go():
280+
async def go():
281281
_, srv, url = await self.create_server('GET', '/', handler)
282282
joiners = Joiners(None)
283-
joiners.reverse_url = lambda path: url
283+
joiners.reverse_url = lambda scheme, path: url
284284
with self.assertRaises(jsonschema.exceptions.ValidationError):
285285
await joiners.get()
286286

@@ -295,14 +295,14 @@ def test_schema_actives(self):
295295
jsonschema.validate(json_sample, Actives.schema)
296296

297297
def test_actives_bad(self):
298-
async def handler(request):
298+
async def handler(request):
299299
await request.read()
300300
return web.Response(body=b'{}', content_type='application/json')
301301

302-
async def go():
302+
async def go():
303303
_, srv, url = await self.create_server('GET', '/', handler)
304304
actives = Actives(None)
305-
actives.reverse_url = lambda path: url
305+
actives.reverse_url = lambda scheme, path: url
306306
with self.assertRaises(jsonschema.exceptions.ValidationError):
307307
await actives.get()
308308

@@ -317,14 +317,14 @@ def test_schema_leavers(self):
317317
jsonschema.validate(json_sample, Leavers.schema)
318318

319319
def test_leavers_bad(self):
320-
async def handler(request):
320+
async def handler(request):
321321
await request.read()
322322
return web.Response(body=b'{}', content_type='application/json')
323323

324-
async def go():
324+
async def go():
325325
_, srv, url = await self.create_server('GET', '/', handler)
326326
leavers = Leavers(None)
327-
leavers.reverse_url = lambda path: url
327+
leavers.reverse_url = lambda scheme, path: url
328328
with self.assertRaises(jsonschema.exceptions.ValidationError):
329329
await leavers.get()
330330

@@ -339,14 +339,14 @@ def test_schema_ud(self):
339339
jsonschema.validate(json_sample, UD.schema)
340340

341341
def test_ud_bad(self):
342-
async def handler(request):
342+
async def handler(request):
343343
await request.read()
344344
return web.Response(body=b'{}', content_type='application/json')
345345

346-
async def go():
346+
async def go():
347347
_, srv, url = await self.create_server('GET', '/', handler)
348348
ud = UD(None)
349-
ud.reverse_url = lambda path: url
349+
ud.reverse_url = lambda scheme, path: url
350350
with self.assertRaises(jsonschema.exceptions.ValidationError):
351351
await ud.get()
352352

@@ -361,14 +361,14 @@ def test_schema_tx(self):
361361
jsonschema.validate(json_sample, TX.schema)
362362

363363
def test_tx_bad(self):
364-
async def handler(request):
364+
async def handler(request):
365365
await request.read()
366366
return web.Response(body=b'{}', content_type='application/json')
367367

368-
async def go():
368+
async def go():
369369
_, srv, url = await self.create_server('GET', '/', handler)
370370
tx = TX(None)
371-
tx.reverse_url = lambda path: url
371+
tx.reverse_url = lambda scheme, path: url
372372
with self.assertRaises(jsonschema.exceptions.ValidationError):
373373
await tx.get()
374374

_ucoinpy_test/api/bma/test_tx.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,28 +121,28 @@ def test_bma_tx_history(self):
121121
jsonschema.validate(json_sample, Blocks.schema)
122122

123123
def test_bma_tx_history_bad(self):
124-
async def handler(request):
124+
async def handler(request):
125125
await request.read()
126126
return web.Response(body=b'{}', content_type='application/json')
127127

128-
async def go():
128+
async def go():
129129
_, srv, url = await self.create_server('GET', '/pubkey', handler)
130130
history = History(None, 'pubkey')
131-
history.reverse_url = lambda path: url
131+
history.reverse_url = lambda scheme, path: url
132132
with self.assertRaises(jsonschema.exceptions.ValidationError):
133133
await history.get()
134134

135135
self.loop.run_until_complete(go())
136136

137137
def test_bma_tx_history_blocks_bad(self):
138-
async def handler(request):
138+
async def handler(request):
139139
await request.read()
140140
return web.Response(body=b'{}', content_type='application/json')
141141

142-
async def go():
142+
async def go():
143143
_, srv, url = await self.create_server('GET', '/pubkey/0/100', handler)
144144
blocks = Blocks(None, 'pubkey', 0, 100)
145-
blocks.reverse_url = lambda path: url
145+
blocks.reverse_url = lambda scheme, path: url
146146
with self.assertRaises(jsonschema.exceptions.ValidationError):
147147
await blocks.get()
148148

@@ -172,14 +172,14 @@ def test_bma_tx_sources(self):
172172
jsonschema.validate(json_sample, Sources.schema)
173173

174174
def test_bma_tx_sources_bad(self):
175-
async def handler(request):
175+
async def handler(request):
176176
await request.read()
177177
return web.Response(body=b'{}', content_type='application/json')
178178

179-
async def go():
179+
async def go():
180180
_, srv, url = await self.create_server('GET', '/pubkey', handler)
181181
sources = Sources(None, 'pubkey')
182-
sources.reverse_url = lambda path: url
182+
sources.reverse_url = lambda scheme, path: url
183183
with self.assertRaises(jsonschema.exceptions.ValidationError):
184184
await sources.get()
185185

_ucoinpy_test/api/bma/test_wot.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ def test_bma_wot_lookup(self):
7070
jsonschema.validate(json_sample, Lookup.schema)
7171

7272
def test_bma_wot_lookup_bad(self):
73-
async def handler(request):
73+
async def handler(request):
7474
await request.read()
7575
return web.Response(body=b'{}', content_type='application/json')
7676

77-
async def go():
77+
async def go():
7878
_, srv, url = await self.create_server('GET', '/pubkey', handler)
7979
lookup = Lookup(None, "pubkey")
80-
lookup.reverse_url = lambda path: url
80+
lookup.reverse_url = lambda scheme, path: url
8181
with self.assertRaises(jsonschema.exceptions.ValidationError):
8282
await lookup.get()
8383

@@ -94,14 +94,14 @@ def test_bma_wot_members(self):
9494
jsonschema.validate(Members.schema, json_sample)
9595

9696
def test_bma_wot_members_bad(self):
97-
async def handler(request):
97+
async def handler(request):
9898
await request.read()
9999
return web.Response(body=b'{}', content_type='application/json')
100100

101-
async def go():
101+
async def go():
102102
_, srv, url = await self.create_server('GET', '/', handler)
103103
members = Members(None)
104-
members.reverse_url = lambda path: url
104+
members.reverse_url = lambda scheme, path: url
105105
with self.assertRaises(jsonschema.exceptions.ValidationError):
106106
await members.get()
107107

@@ -144,21 +144,21 @@ def test_bma_wot_cert(self):
144144
jsonschema.validate(json_sample, CertifiedBy.schema)
145145

146146
def test_bma_wot_certifiers_bad(self):
147-
async def handler(request):
147+
async def handler(request):
148148
await request.read()
149149
return web.Response(body=b'{}', content_type='application/json')
150150

151-
async def go():
151+
async def go():
152152
_, srv, url = await self.create_server('GET', '/pubkey', handler)
153153
certsof = CertifiersOf(None, 'pubkey')
154-
certsof.reverse_url = lambda path: url
154+
certsof.reverse_url = lambda scheme, path: url
155155
with self.assertRaises(jsonschema.exceptions.ValidationError):
156156
await certsof.get()
157157

158158
self.loop.run_until_complete(go())
159159

160160
def test_bma_wot_certifiers_inner_bad(self):
161-
async def handler(request):
161+
async def handler(request):
162162
await request.read()
163163
return web.Response(body=bytes(json.dumps({
164164
"pubkey": "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
@@ -180,24 +180,24 @@ async def handler(request):
180180
]
181181
}), "utf-8"), content_type='application/json')
182182

183-
async def go():
183+
async def go():
184184
_, srv, url = await self.create_server('GET', '/pubkey', handler)
185185
certsof = CertifiersOf(None, 'pubkey')
186-
certsof.reverse_url = lambda path: url
186+
certsof.reverse_url = lambda scheme, path: url
187187
with self.assertRaises(jsonschema.exceptions.ValidationError):
188188
await certsof.get()
189189

190190
self.loop.run_until_complete(go())
191191

192192
def test_bma_wot_certified_bad(self):
193-
async def handler(request):
193+
async def handler(request):
194194
await request.read()
195195
return web.Response(body=b'{}', content_type='application/json')
196196

197-
async def go():
197+
async def go():
198198
_, srv, url = await self.create_server('GET', '/pubkey', handler)
199199
certby = CertifiedBy(None, 'pubkey')
200-
certby.reverse_url = lambda path: url
200+
certby.reverse_url = lambda scheme, path: url
201201
with self.assertRaises(jsonschema.exceptions.ValidationError):
202202
await certby.get()
203203

_ucoinpy_test/api/test_bma.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ class Test_BMA_API(unittest.TestCase):
88
def test_reverse_url_complete(self):
99
endpoint = BMAEndpoint("test.com", "124.2.2.1", "2001:0db8:0000:85a3:0000:0000:ac1f:8001 ", 9092)
1010
api = API(endpoint.conn_handler(), "any")
11-
self.assertEqual(api.reverse_url("/test/url"), "http://test.com:9092/any/test/url")
11+
self.assertEqual(api.reverse_url("http", "/test/url"), "http://test.com:9092/any/test/url")
1212

1313
def test_reverse_url_only_ipv4(self):
1414
endpoint = BMAEndpoint(None, "124.2.2.1", None, 9092)
1515
api = API(endpoint.conn_handler(), "any")
16-
self.assertEqual(api.reverse_url("/test/url"), "http://124.2.2.1:9092/any/test/url")
16+
self.assertEqual(api.reverse_url("http", "/test/url"), "http://124.2.2.1:9092/any/test/url")
1717

1818
def test_reverse_url_only_ipv6(self):
1919
endpoint = BMAEndpoint(None, None, "2001:0db8:0000:85a3:0000:0000:ac1f:8001", 9092)
2020
api = API(endpoint.conn_handler(), "any")
21-
self.assertEqual(api.reverse_url("/test/url"), "http://2001:0db8:0000:85a3:0000:0000:ac1f:8001:9092/any/test/url")
21+
self.assertEqual(api.reverse_url("http", "/test/url"), "http://2001:0db8:0000:85a3:0000:0000:ac1f:8001:9092/any/test/url")

_ucoinpy_test/documents/test_certification.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def test_certifications(self):
4747
cert = Certification.from_inline(version, currency, blockhash, cert_inlines[0])
4848
self.assertEqual(cert.pubkey_from, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
4949
self.assertEqual(cert.pubkey_to, "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk")
50-
self.assertEqual(cert.blocknumber, 0)
51-
self.assertEqual(cert.blockhash, blockhash)
50+
self.assertEqual(cert.blockid.number, 0)
51+
self.assertEqual(cert.blockid.sha_hash, blockhash)
5252
self.assertEqual(cert.signatures[0], "TgmDuMxZdyutroj9jiLJA8tQp/389JIzDKuxW5+h7GIfjDu1ZbwI7HNm5rlUDhR2KreaV/QJjEaItT4Cf75rCQ==")
5353

5454
cert = Certification.from_inline(version, currency, blockhash, cert_inlines[1])
5555
self.assertEqual(cert.pubkey_from, "9fx25FmeBDJcikZLWxK5HuzKNbY6MaWYXoK1ajteE42Y")
5656
self.assertEqual(cert.pubkey_to, "8Fi1VSTbjkXguwThF4v2ZxC5whK7pwG2vcGTkPUPjPGU")
57-
self.assertEqual(cert.blocknumber, 0)
58-
self.assertEqual(cert.blockhash, blockhash)
57+
self.assertEqual(cert.blockid.number, 0)
58+
self.assertEqual(cert.blockid.sha_hash, blockhash)
5959
self.assertEqual(cert.signatures[0], "qn/XNJjaGIwfnR+wGrDME6YviCQbG+ywsQWnETlAsL6q7o3k1UhpR5ZTVY9dvejLKuC+1mUEXVTmH+8Ib55DBA==")

0 commit comments

Comments
 (0)