Exemple #1
0
def test_invalid_dsn(raw):
    with pytest.raises(dsn.DSNValueError):
        dsn.DSN(raw)
Exemple #2
0
def test_is_private(raw):
    assert dsn.DSN(raw).info.is_private
Exemple #3
0
#!/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
Exemple #4
0
def test_is_internal(raw):
    assert dsn.DSN(raw).info.is_internal
Exemple #5
0
def test_sqlite_dsn(raw):
    assert dsn.DSN(raw).info.address == raw