Exemple #1
0
    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')
Exemple #2
0
 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 == ''
Exemple #3
0
 def __init__(self, dsn):
     self.__dsn = dsntool.DSN(dsn)
Exemple #4
0
 def test_copy(self, sample_dsn):
     r = dsntool.DSN(sample_dsn)
     assert r.copy().get_url() == r.get_url()
Exemple #5
0
 def test_field_update(self, sample_dsn):
     r = dsntool.DSN(sample_dsn)
     r.username = '******'
     assert r.get_url() == 'scheme://*****:*****@host/foo'
Exemple #6
0
 def test_set_default_call(self, sample_dsn):
     r = dsntool.DSN(sample_dsn)
     r.set_default('port', 1234)
     assert r.port == 1234
Exemple #7
0
 def test_set_default_init(self, sample_dsn):
     assert dsntool.DSN(sample_dsn, port=1235).port == 1235
Exemple #8
0
 def test_set_default_missed(self, sample_dsn):
     assert dsntool.DSN(sample_dsn).port is None
Exemple #9
0
 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()