def test_DSN(self, dsn_example): for dsn, expected in dsn_example: r = dsntool.DSN(dsn) for k, v in expected.iteritems(): assert v == getattr(r, k) with pytest.raises(AssertionError): r = dsntool.DSN('//host.com:1234')
def test_unpack(self): dsn = 'scheme://*****:*****@host:1234/foo' scheme, netloc, path, params, query, fragment = dsntool.DSN(dsn) assert scheme == 'scheme' assert netloc == 'username:password@host:1234' assert path == '/foo' assert params == '' assert query == {} assert fragment == ''
def __init__(self, dsn): self.__dsn = dsntool.DSN(dsn)
def test_copy(self, sample_dsn): r = dsntool.DSN(sample_dsn) assert r.copy().get_url() == r.get_url()
def test_field_update(self, sample_dsn): r = dsntool.DSN(sample_dsn) r.username = '******' assert r.get_url() == 'scheme://*****:*****@host/foo'
def test_set_default_call(self, sample_dsn): r = dsntool.DSN(sample_dsn) r.set_default('port', 1234) assert r.port == 1234
def test_set_default_init(self, sample_dsn): assert dsntool.DSN(sample_dsn, port=1235).port == 1235
def test_set_default_missed(self, sample_dsn): assert dsntool.DSN(sample_dsn).port is None
def test_geturl(self): dsn = 'scheme://*****:*****@host:1234/bar/che?option1=opt_val1&option2=opt_val2#anchor' r = dsntool.DSN(dsn) assert dsn == r.get_url()