Пример #1
0
 def test_update_keywords(self):
     instance = QSO("key=value1&key=value2&bar=baz")
     instance.update(bar="diz")
     assert str(instance) == "key=value1&key=value2&bar=diz"
     instance.update(diz="doz")
     assert str(instance) == "key=value1&key=value2&bar=diz&diz=doz"
     instance.update(key="value3")
     assert str(instance) == "bar=diz&diz=doz&key=value3"
Пример #2
0
    def test_set_new(self, instance, empty):
        instance['foo'] = 'bar'
        assert str(
            instance
        ) == 'http://*****:*****@example.com/over/there?name=ferret&foo=bar#anchor'

        empty['bar'] = 'baz'
        assert str(empty) == 'http://example.com/over/there?bar=baz'
Пример #3
0
 def test_insert(self):
     instance = QSO("foo&bar&baz")
     instance.insert(0, "diz")
     assert str(instance) == "diz&foo&bar&baz"
     instance.insert(-1, "doz")
     assert str(instance) == "diz&foo&bar&doz&baz"
     assert len(instance.groups[None]) == 5
     instance.insert(99, "twentyseven")
     assert str(instance) == "diz&foo&bar&doz&baz&twentyseven"
Пример #4
0
    def test_protocol_relative_shortcut(self, instance):
        https = URI("https://")

        instance = https // instance
        assert str(
            instance
        ) == "https://*****:*****@example.com/over/there?name=ferret#anchor"
Пример #5
0
 def test_numeric_deletion(self):
     instance = QSO('key=value1&key=value2&bar=baz')
     assert len(instance) == 3
     assert len(instance.groups['key']) == 2
     del instance[0]
     assert len(instance) == 2
     assert len(instance.groups['key']) == 1
     assert str(instance) == 'key=value2&bar=baz'
Пример #6
0
 def test_reverse(self):
     instance = QSO("key=value1&key=value2&bar=baz")
     instance.reverse()
     assert str(instance) == "bar=baz&key=value2&key=value1"
     assert tuple(instance['key']) == ("value2", "value1")
Пример #7
0
 def test_empty(self):
     instance = URI()
     assert str(instance) == ""
     assert not instance
Пример #8
0
 def test_set_replace(self, instance):
     instance['name'] = 'lemur'
     assert str(
         instance
     ) == 'http://*****:*****@example.com/over/there?name=lemur#anchor'
Пример #9
0
 def test_path_usage(self):
     path = Path("/foo/bar/baz")
     instance = URI(path)
     assert instance.scheme == 'file'
     assert str(instance) == "file:///foo/bar/baz"
Пример #10
0
 def test_rooted_path_authority_resolution(self):
     uri = URI('http://example.com/diz')
     uri.path = '/foo/bar'
     assert str(uri) == "http://example.com/foo/bar"
Пример #11
0
 def test_relative_assignment(self, instance):
     instance /= "bar"
     assert str(instance) == "http://*****:*****@example.com/over/bar"
Пример #12
0
 def test_resolution_overriding(self, instance):
     expect = "http://example.com/over/there?name=ferret#anchor"
     assert str(instance.resolve(user=None, password=None)) == expect
Пример #13
0
 def test_rooted(self, instance):
     instance = instance / "/foo"
     assert str(instance) == "http://*****:*****@example.com/foo"
Пример #14
0
 def test_pop_examples(self, src, key, expect, value):
     instance = QSO(src)
     result = instance.pop(key)
     assert str(instance) == expect
     assert result == value
Пример #15
0
 def test_deletion_examples(self, src, key, expect, value):
     instance = QSO(src)
     del instance[key]
     assert str(instance) == expect
Пример #16
0
 def test_inline_add(self, src, change, expect):
     instance = QSO(src)
     instance += change
     assert str(instance) == expect
Пример #17
0
 def test_update(self, src, change, expect):
     instance = QSO(src)
     instance.update(change)
     assert str(instance) == expect
Пример #18
0
 def test_relative(self, instance):
     instance = instance / "foo"
     assert str(instance) == "http://*****:*****@example.com/over/foo"
Пример #19
0
 def test_str(self, string, args, kw):
     instance = QSO(string)
     assert str(instance) == string
Пример #20
0
 def test_resolution_by_uri(self, instance):
     assert str(
         instance.resolve('/baz')) == "http://*****:*****@example.com/baz"
     assert str(
         instance.resolve('baz')) == "http://*****:*****@example.com/over/baz"
Пример #21
0
    def test_named_assignment(self, string, args, kw):
        instance = QSO(string)
        instance['doz'] = '27'

        assert str(instance).endswith(('&' if (args or kw) else '') + 'doz=27')
Пример #22
0
    def test_qs_assignment(self):
        instance = URI("http://example.com")
        assert str(instance) == "http://example.com/"

        instance.qs = "foo=bar"
        assert str(instance) == "http://example.com/?foo=bar"
Пример #23
0
    def test_grouped_replacement(self, string, args, kw):
        instance = QSO(string)

        instance['foo'] = 'doz'

        assert 'foo=doz' in str(instance)
Пример #24
0
    def test_empty_protocol_assignment(self, empty):
        assert empty.scheme == 'http'

        empty.scheme = None
        assert str(empty) == "//example.com/over/there"
Пример #25
0
 def test_string_identity(self, string, args, name, value, valid):
     bucket = Bucket(string)
     assert str(bucket) == string
Пример #26
0
 def test_repr(self, string, args, name, value, valid):
     bucket = Bucket(*args)
     assert repr(bucket) == "Bucket(" + str(bucket) + ")"
Пример #27
0
 def test_identity(self, string, attributes):
     instance = URI(string)
     assert str(instance) == attributes['uri']
Пример #28
0
 def test_del(self, instance):
     del instance['name']
     assert str(
         instance) == 'http://*****:*****@example.com/over/there#anchor'
Пример #29
0
 def test_multiple_reassignment(self, src, key, value, expect):
     instance = QSO(src)
     instance[key] = value
     assert str(instance) == expect