weechat-matrix/tests/server_test.py
Damir Jelić b884536e7e server: Don't use the address in the config for connection establishment.
The address in the config can contain subpaths and it doesn't make sense
for a socket to connect to this address. The net location without the
subpath is now contained in server.address.
2019-02-03 22:56:10 +01:00

26 lines
873 B
Python

from matrix.server import MatrixServer
from matrix._weechat import MockConfig
import matrix.globals as G
G.CONFIG = MockConfig()
class TestClass(object):
def test_address_parsing(self):
netloc, host = MatrixServer._parse_url("example.org", "443")
assert host == "example.org:443"
assert netloc == "example.org"
netloc, host = MatrixServer._parse_url("example.org/_matrix", "443")
assert host == "example.org:443/_matrix"
assert netloc == "example.org"
netloc, host = MatrixServer._parse_url(
"https://example.org/_matrix",
"443"
)
assert host == "example.org:443/_matrix"
assert netloc == "example.org"
netloc, host = MatrixServer._parse_url("https://example.org", "443")
assert host == "example.org:443"
assert netloc == "example.org"