def test_invalid_dsn(raw): with pytest.raises(dsn.DSNValueError): dsn.DSN(raw)
def test_is_private(raw): assert dsn.DSN(raw).info.is_private
#!/usr/bin/env python # -*- coding: UTF-8 -*- import json from urllib.parse import quote import pytest from typic.types import dsn DSN_RAW = "mysql://*****:*****@foobar.net:3306/db" DSN = dsn.DSN(DSN_RAW) DSN_NO_PORT = dsn.DSN("mysql://*****:*****@foobar.net/db") @pytest.mark.parametrize( argnames=("name", "expected"), argvalues=[ ("driver", "mysql"), ("host", "foobar.net"), ("username", "foo"), ("password", "bar"), ("port", 3306), ("name", "/db"), ("address", DSN), ("address_encoded", quote(DSN_RAW)), ], ) def test_dsn_info_attrs(name, expected): value = getattr(DSN.info, name) assert expected == value
def test_is_internal(raw): assert dsn.DSN(raw).info.is_internal
def test_sqlite_dsn(raw): assert dsn.DSN(raw).info.address == raw