Skip to content

Commit

Permalink
test: bind_unix_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanaasagi committed Sep 25, 2019
1 parent baa5d03 commit 55958e7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import os
import socket
import tempfile

import pytest

Expand Down Expand Up @@ -63,8 +65,26 @@ def test_logger():
def test_socket_bind():
config = Config(app=asgi_app)
config.load()
sock = config.bind_socket()

assert isinstance(config.bind_socket(), socket.socket)
assert sock.family.name == "AF_INET"
assert sock.type.name == "SOCK_STREAM"


def test_bind_unix_socket():
with tempfile.NamedTemporaryFile() as f:
uds = f.name

config = Config(app=asgi_app, uds=uds)
config.load()
sock = config.bind_unix_socket()

assert isinstance(sock, socket.socket)
assert sock.family.name == "AF_UNIX"
assert sock.type.name == "SOCK_STREAM"

os.remove(uds)


def test_ssl_config(certfile_and_keyfile):
Expand Down

0 comments on commit 55958e7

Please sign in to comment.