def testTcpPortBindings(self): self.assertEqual( build(port=1234, host="example.com"), ["tcp:port=1234:interface=example.com"], ) self.assertEqual(build(port=8000, host="127.0.0.1"), ["tcp:port=8000:interface=127.0.0.1"]) self.assertEqual(build(port=8000, host="[200a::1]"), [r"tcp:port=8000:interface=200a\:\:1"]) self.assertEqual(build(port=8000, host="200a::1"), [r"tcp:port=8000:interface=200a\:\:1"]) # incomplete port/host kwargs raise errors self.assertRaises(ValueError, build, port=123) self.assertRaises(ValueError, build, host="example.com")
def testMultipleEnpoints(self): self.assertEqual( sorted( build( file_descriptor=123, unix_socket="/tmp/daphneplus.sock", port=8080, host="10.0.0.1", )), sorted([ "tcp:port=8080:interface=10.0.0.1", "unix:/tmp/daphneplus.sock", "fd:fileno=123", ]), )
def testFileDescriptorBinding(self): self.assertEqual(build(file_descriptor=5), ["fd:fileno=5"])
def testUnixSocketBinding(self): self.assertEqual(build(unix_socket="/tmp/daphneplus.sock"), ["unix:/tmp/daphneplus.sock"])
def testBasics(self): self.assertEqual(build(), [], msg="Empty list returned when no kwargs given")