def test_server(): server = socket_server_init() server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.bind(('localhost', 12345)) server.listen(1) conn, addr = server.accept() thread = threading.Thread(target=socket_server_respond_request, args=(conn, "testfile.txt")) thread.start() thread.join() server.close()
def test_server(): server = socket_server_init() server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.bind(('localhost', 12345)) server.listen(1) conn, addr = server.accept() data = { "group": [ { "userID": "" }, { "userID": "" }, { "userID": "" }, { "userID": "" }, { "userID": "" }, ], "filenames": [ { "name": "test.wav" }, { "name": "fake_file.wav"} ], "play": "false", "stop": "false", "parameters": { "volume": "0", "echo": { "apply": "false", "delay": "10.0", "feedback": "0.0", "dry": "0.0", "wet": "0.0" }, "equalizer": { "apply": "false", "lowgain": "0.0", "midgain": "0.0", "highgain": "0.0" } } } s3 = boto3.resource('s3') bucketName = "testing-pi" target_bucket = s3.Bucket(bucketName) files = data["filenames"] sqs_response = (files, data, None, None, False) thread_send(bucketName, target_bucket, sqs_response, conn) server.close()
def test_server_connection(): s = None s = socket_server_init() thread = threading.Thread(target=socket_server_accept_connection, args=(s,)) thread.start() HOST = 'localhost' PORT = 12345 datalen = None data = None client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) time.sleep(1) client_socket.connect((HOST, PORT)) client_socket.sendall(bytes("Hello from pytest client", 'utf-8')) datalen = client_socket.recv(1024) data = client_socket.recv(1024) thread.join() client_socket.close() assert datalen != None assert data != None
def test_initalization(): s = None s = socket_server_init() assert s != None