aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/websocket-client
diff options
context:
space:
mode:
authormaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 12:29:46 +0300
committermaxim-yurchuk <maxim-yurchuk@yandex-team.com>2024-10-09 13:14:22 +0300
commit9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch)
treea8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/websocket-client
parenta44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff)
downloadydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz
publishFullContrib: true for ydb
<HIDDEN_URL> commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/websocket-client')
-rw-r--r--contrib/python/websocket-client/py2/patches/01-fix-tests.patch33
-rw-r--r--contrib/python/websocket-client/py3/patches/01-fix-tests.patch24
-rw-r--r--contrib/python/websocket-client/py3/websocket/tests/echo-server.py23
3 files changed, 80 insertions, 0 deletions
diff --git a/contrib/python/websocket-client/py2/patches/01-fix-tests.patch b/contrib/python/websocket-client/py2/patches/01-fix-tests.patch
new file mode 100644
index 0000000000..83acc3d9c6
--- /dev/null
+++ b/contrib/python/websocket-client/py2/patches/01-fix-tests.patch
@@ -0,0 +1,33 @@
+--- contrib/python/websocket-client/py2/websocket/tests/test_http.py (index)
++++ contrib/python/websocket-client/py2/websocket/tests/test_http.py (working tree)
+@@ -66,7 +66,8 @@ class HeaderSockMock(SockMock):
+
+ def __init__(self, fname):
+ SockMock.__init__(self)
+- path = os.path.join(os.path.dirname(__file__), fname)
++ import yatest.common
++ path = yatest.common.source_path(os.path.join('contrib/python/websocket-client/py2/websocket/tests', fname))
+ with open(path, "rb") as f:
+ self.add_packet(f.read())
+
+@@ -91,7 +92,7 @@ class HttpTest(unittest.TestCase):
+ self.assertRaises(ws.WebSocketProxyException, _tunnel, HeaderSockMock("data/header01.txt"), "example.com", 80, ("username", "password"))
+ self.assertRaises(ws.WebSocketProxyException, _tunnel, HeaderSockMock("data/header02.txt"), "example.com", 80, ("username", "password"))
+
+- def testConnect(self):
++ def _testConnect(self):
+ # Not currently testing an actual proxy connection, so just check whether TypeError is raised
+ self.assertRaises(TypeError, _open_proxied_socket, "wss://example.com", OptsList(), proxy_info(http_proxy_host="example.com", http_proxy_port="8080", proxy_type="http"))
+ self.assertRaises(TypeError, _open_proxied_socket, "wss://example.com", OptsList(), proxy_info(http_proxy_host="example.com", http_proxy_port="8080", proxy_type="socks4"))
+--- contrib/python/websocket-client/py2/websocket/tests/test_websocket.py (index)
++++ contrib/python/websocket-client/py2/websocket/tests/test_websocket.py (working tree)
+@@ -99,7 +99,8 @@ class HeaderSockMock(SockMock):
+
+ def __init__(self, fname):
+ SockMock.__init__(self)
+- path = os.path.join(os.path.dirname(__file__), fname)
++ import yatest.common
++ path = yatest.common.source_path(os.path.join('contrib/python/websocket-client/py2/websocket/tests', fname))
+ with open(path, "rb") as f:
+ self.add_packet(f.read())
+
diff --git a/contrib/python/websocket-client/py3/patches/01-fix-tests.patch b/contrib/python/websocket-client/py3/patches/01-fix-tests.patch
new file mode 100644
index 0000000000..db6ba4b667
--- /dev/null
+++ b/contrib/python/websocket-client/py3/patches/01-fix-tests.patch
@@ -0,0 +1,24 @@
+--- contrib/python/websocket-client/py3/websocket/tests/test_http.py (index)
++++ contrib/python/websocket-client/py3/websocket/tests/test_http.py (working tree)
+@@ -74,7 +74,8 @@ class HeaderSockMock(SockMock):
+
+ def __init__(self, fname):
+ SockMock.__init__(self)
+- path = os.path.join(os.path.dirname(__file__), fname)
++ import yatest.common
++ path = yatest.common.source_path(os.path.join('contrib/python/websocket-client/py3/websocket/tests', fname))
+ with open(path, "rb") as f:
+ self.add_packet(f.read())
+
+--- contrib/python/websocket-client/py3/websocket/tests/test_websocket.py (index)
++++ contrib/python/websocket-client/py3/websocket/tests/test_websocket.py (working tree)
+@@ -86,7 +86,8 @@ class HeaderSockMock(SockMock):
+
+ def __init__(self, fname):
+ SockMock.__init__(self)
+- path = os.path.join(os.path.dirname(__file__), fname)
++ import yatest.common
++ path = yatest.common.source_path(os.path.join('contrib/python/websocket-client/py3/websocket/tests', fname))
+ with open(path, "rb") as f:
+ self.add_packet(f.read())
+
diff --git a/contrib/python/websocket-client/py3/websocket/tests/echo-server.py b/contrib/python/websocket-client/py3/websocket/tests/echo-server.py
new file mode 100644
index 0000000000..5d1e87087b
--- /dev/null
+++ b/contrib/python/websocket-client/py3/websocket/tests/echo-server.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+# From https://github.com/aaugustin/websockets/blob/main/example/echo.py
+
+import asyncio
+import os
+
+import websockets
+
+LOCAL_WS_SERVER_PORT = int(os.environ.get("LOCAL_WS_SERVER_PORT", "8765"))
+
+
+async def echo(websocket):
+ async for message in websocket:
+ await websocket.send(message)
+
+
+async def main():
+ async with websockets.serve(echo, "localhost", LOCAL_WS_SERVER_PORT):
+ await asyncio.Future() # run forever
+
+
+asyncio.run(main())