Skip to content
Snippets Groups Projects
Commit cdf47ec4 authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] #58 fix tests.api.ws2p.test_ws2p after rebase

parent 887842ba
No related branches found
No related tags found
No related merge requests found
...@@ -3,17 +3,16 @@ import unittest ...@@ -3,17 +3,16 @@ import unittest
import jsonschema import jsonschema
from duniterpy.api.client import Client, parse_text from duniterpy.api.client import parse_text
from duniterpy.api.endpoint import BMAEndpoint from duniterpy.api.ws2p.network import WS2P_HEADS_SCHEMA
from duniterpy.api.ws2p.network import heads, WS2P_HEADS_SCHEMA
from duniterpy.api.ws2p.requests import BLOCK_RESPONSE_SCHEMA, ERROR_RESPONSE_SCHEMA, BLOCKS_RESPONSE_SCHEMA, \ from duniterpy.api.ws2p.requests import BLOCK_RESPONSE_SCHEMA, ERROR_RESPONSE_SCHEMA, BLOCKS_RESPONSE_SCHEMA, \
REQUIREMENTS_RESPONSE_SCHEMA REQUIREMENTS_RESPONSE_SCHEMA
from duniterpy.documents import Identity, BlockUID from duniterpy.documents import Identity, BlockUID
from duniterpy.documents.ws2p.messages import DocumentMessage from duniterpy.documents.ws2p.messages import DocumentMessage
from tests.api.webserver import WebFunctionalSetupMixin, web from tests.api.webserver import WebFunctionalSetupMixin
class TestWs2pHeads(WebFunctionalSetupMixin, unittest.TestCase): class TestWs2p(WebFunctionalSetupMixin, unittest.TestCase):
def test_block(self): def test_block(self):
json_sample = { json_sample = {
...@@ -53,20 +52,6 @@ class TestWs2pHeads(WebFunctionalSetupMixin, unittest.TestCase): ...@@ -53,20 +52,6 @@ class TestWs2pHeads(WebFunctionalSetupMixin, unittest.TestCase):
jsonschema.validate(json_sample, WS2P_HEADS_SCHEMA) jsonschema.validate(json_sample, WS2P_HEADS_SCHEMA)
def test_ws2p_heads_bad(self):
async def handler(request):
await request.read()
return web.Response(body=b'{}', content_type='application/json')
async def go():
_, port, url = await self.create_server('GET', '/network/ws2p/heads', handler)
with self.assertRaises(jsonschema.ValidationError):
client = Client(BMAEndpoint("127.0.0.1", "", "", port))
await client(heads)
await client.close()
self.loop.run_until_complete(go())
def test_error_response_validation(self): def test_error_response_validation(self):
error_response_string = """{"resId":"cfe10cc4","err":"Error message"}""" error_response_string = """{"resId":"cfe10cc4","err":"Error message"}"""
error_response = parse_text(error_response_string, ERROR_RESPONSE_SCHEMA) error_response = parse_text(error_response_string, ERROR_RESPONSE_SCHEMA)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment