2019-02-03 10:21:59 +01:00
|
|
|
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):
|
2019-02-03 22:56:10 +01:00
|
|
|
netloc, host = MatrixServer._parse_url("example.org", "443")
|
2019-02-03 10:21:59 +01:00
|
|
|
assert host == "example.org:443"
|
2019-02-03 22:56:10 +01:00
|
|
|
assert netloc == "example.org"
|
2019-02-03 10:21:59 +01:00
|
|
|
|
2019-02-03 22:56:10 +01:00
|
|
|
netloc, host = MatrixServer._parse_url("example.org/_matrix", "443")
|
2019-02-03 10:21:59 +01:00
|
|
|
assert host == "example.org:443/_matrix"
|
2019-02-03 22:56:10 +01:00
|
|
|
assert netloc == "example.org"
|
2019-02-03 10:21:59 +01:00
|
|
|
|
2019-02-03 22:56:10 +01:00
|
|
|
netloc, host = MatrixServer._parse_url(
|
|
|
|
"https://example.org/_matrix",
|
|
|
|
"443"
|
|
|
|
)
|
2019-02-03 10:21:59 +01:00
|
|
|
assert host == "example.org:443/_matrix"
|
2019-02-03 22:56:10 +01:00
|
|
|
assert netloc == "example.org"
|
2019-02-03 10:21:59 +01:00
|
|
|
|
2019-02-03 22:56:10 +01:00
|
|
|
netloc, host = MatrixServer._parse_url("https://example.org", "443")
|
2019-02-03 10:21:59 +01:00
|
|
|
assert host == "example.org:443"
|
2019-02-03 22:56:10 +01:00
|
|
|
assert netloc == "example.org"
|