Restructure app so isort actually runs

This commit is contained in:
Jake Howard 2018-12-07 23:34:59 +00:00
parent 39c69aac5f
commit 1b69e09276
Signed by: jake
GPG Key ID: 57AFB45680EDD477
5 changed files with 13 additions and 22 deletions

View File

@ -1,11 +0,0 @@
import socket
import ujson
from ipc_unix.utils import read_payload
def send_to(socket_path, data):
with socket.socket(socket.AF_UNIX, type=socket.SOCK_STREAM) as sock:
sock.connect(socket_path)
sock.sendall(ujson.dumps(data).encode() + b"\n")
return read_payload(sock)

View File

@ -1,3 +1,4 @@
import socket
import socketserver
import threading
@ -5,6 +6,13 @@ import ujson
from ipc_unix.utils import read_payload
def send_to(socket_path, data):
with socket.socket(socket.AF_UNIX, type=socket.SOCK_STREAM) as sock:
sock.connect(socket_path)
sock.sendall(ujson.dumps(data).encode() + b"\n")
return read_payload(sock)
class RequestHandler(socketserver.BaseRequestHandler):
def handle_request(self, request):
raise NotImplementedError("Failed to override `handle_request`")

View File

@ -1,9 +1,9 @@
from ipc_unix import server
from ipc_unix.simple import Server
import tempfile
import os
class EchoServer(server.Server):
class EchoServer(Server):
def handle_request(self, request):
return request

View File

@ -1,6 +0,0 @@
from unittest import TestCase
class BasicTestCase(TestCase):
def test_something_basic(self):
self.assertTrue(True)

View File

@ -1,16 +1,16 @@
from functools import partial
from unittest import TestCase
from ipc_unix import client
from ipc_unix.simple import send_to
from tests import EchoServer, get_temp_file_path
class BasicServerTestCase(TestCase):
class SimpleServerTestCase(TestCase):
def setUp(self):
self.socket_path = get_temp_file_path()
self.server = EchoServer(self.socket_path)
self.server.serve_in_thread()
self.send_to_client = partial(client.send_to, self.socket_path)
self.send_to_client = partial(send_to, self.socket_path)
def tearDown(self):
self.server.shutdown()