示例#1
0
    def test_from_dict(self):
        data = [('layers', 'foo,bar'), ('laYERs', 'baz'), ('crs', 'EPSG:4326')]
        nc_dict = NoCaseMultiDict(data)
        print(nc_dict)

        for name in ('layers', 'LAYERS', 'lAYeRS'):
            assert name in nc_dict, name + ' not found'
        assert nc_dict.get_all('layers') == ['foo,bar', 'baz']
        assert nc_dict.get_all('crs') == ['EPSG:4326']
示例#2
0
    def test_from_dict(self):
        data = [('layers', 'foo,bar'), ('laYERs', 'baz'), ('crs', 'EPSG:4326')]
        nc_dict = NoCaseMultiDict(data)
        print(nc_dict)

        for name in ('layers', 'LAYERS', 'lAYeRS'):
            assert name in nc_dict, name + ' not found'
        assert nc_dict.get_all('layers') == ['foo,bar', 'baz']
        assert nc_dict.get_all('crs') == ['EPSG:4326']
示例#3
0
    def test_from_dict(self):
        data = [("layers", "foo,bar"), ("laYERs", "baz"), ("crs", "EPSG:4326")]
        nc_dict = NoCaseMultiDict(data)
        print(nc_dict)

        for name in ("layers", "LAYERS", "lAYeRS"):
            assert name in nc_dict, name + " not found"
        assert nc_dict.get_all("layers") == ["foo,bar", "baz"]
        assert nc_dict.get_all("crs") == ["EPSG:4326"]
示例#4
0
    def test_from_dict(self):
        data = [("layers", "foo,bar"), ("laYERs", "baz"), ("crs", "EPSG:4326")]
        nc_dict = NoCaseMultiDict(data)
        print(nc_dict)

        for name in ("layers", "LAYERS", "lAYeRS"):
            assert name in nc_dict, name + " not found"
        assert nc_dict.get_all("layers") == ["foo,bar", "baz"]
        assert nc_dict.get_all("crs") == ["EPSG:4326"]
示例#5
0
 def test_iteritems(self):
     data = dict([('LAYERS', 'foo,bar'), ('laYERs', 'baz'), ('crs', 'EPSG:4326')])
     nc_dict = NoCaseMultiDict(data)
     print nc_dict
 
     itr = nc_dict.iteritems()
     key, values = itr.next()
     assert key == 'LAYERS' and values == ['foo,bar', 'baz']
     key, values = itr.next()
     assert key == 'crs' and values == ['EPSG:4326']
示例#6
0
    def test_iteritems(self):
        data = [("LAYERS", "foo,bar"), ("laYERs", "baz"), ("crs", "EPSG:4326")]
        nc_dict = NoCaseMultiDict(data)

        for key, values in nc_dict.iteritems():
            if key in ("LAYERS", "laYERs"):
                assert values == ["foo,bar", "baz"]
            elif key == "crs":
                assert values == ["EPSG:4326"]
            else:
                assert False, "unexpected key " + key
示例#7
0
    def test_iteritems(self):
        data = [('LAYERS', 'foo,bar'), ('laYERs', 'baz'), ('crs', 'EPSG:4326')]
        nc_dict = NoCaseMultiDict(data)

        for key, values in nc_dict.iteritems():
            if key in ('LAYERS', 'laYERs'):
                assert values == ['foo,bar', 'baz']
            elif key == 'crs':
                assert values == ['EPSG:4326']
            else:
                assert False, 'unexpected key ' + key
示例#8
0
    def test_iteritems(self):
        data = dict([('LAYERS', 'foo,bar'), ('laYERs', 'baz'),
                     ('crs', 'EPSG:4326')])
        nc_dict = NoCaseMultiDict(data)
        print nc_dict

        itr = nc_dict.iteritems()
        key, values = itr.next()
        assert key == 'LAYERS' and values == ['foo,bar', 'baz']
        key, values = itr.next()
        assert key == 'crs' and values == ['EPSG:4326']
示例#9
0
    def test_iteritems(self):
        data = [('LAYERS', 'foo,bar'), ('laYERs', 'baz'), ('crs', 'EPSG:4326')]
        nc_dict = NoCaseMultiDict(data)

        for key, values in nc_dict.iteritems():
            if key in ('LAYERS', 'laYERs'):
                assert values == ['foo,bar', 'baz']
            elif key == 'crs':
                assert values == ['EPSG:4326']
            else:
                assert False, 'unexpected key ' + key
示例#10
0
    def test_iteritems(self):
        data = [("LAYERS", "foo,bar"), ("laYERs", "baz"), ("crs", "EPSG:4326")]
        nc_dict = NoCaseMultiDict(data)

        for key, values in nc_dict.iteritems():
            if key in ("LAYERS", "laYERs"):
                assert values == ["foo,bar", "baz"]
            elif key == "crs":
                assert values == ["EPSG:4326"]
            else:
                assert False, "unexpected key " + key
示例#11
0
文件: path.py 项目: trondmm/mapproxy
def dimensions_part(dimensionlist, dimensions):
    """
    Return the subpath where all tiles for `dimensions` will be stored.
    >>> dimensions_part(['reference-time', 'time'], {"time": "2016-11-24T18:00Z", "reference-time": "2016-11-24T00:00Z"})
    '2016-11-24T00:00Z/2016-11-24T18:00Z'
    """
    if dimensionlist:
        dims = NoCaseMultiDict(dimensions)
        return os.path.join(*(map(lambda k: str(dims.get(k, 'default')),
                                  dimensionlist)))
    else:
        return ""
示例#12
0
 def test_missing_key(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar')])
     try:
         nc_dict['bar']
         assert False, 'Did not throw KeyError exception.'
     except KeyError:
         pass
示例#13
0
 def test_missing_key(self):
     nc_dict = NoCaseMultiDict([("foo", "bar")])
     try:
         nc_dict["bar"]
         assert False, "Did not throw KeyError exception."
     except KeyError:
         pass
示例#14
0
 def test_get(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42')])
     assert nc_dict.get('bar') == None
     assert nc_dict.get('bar', 'default_bar') == 'default_bar'
     assert nc_dict.get('num') == '42'
     assert nc_dict.get('num', type_func=int) == 42
     assert nc_dict.get('foo') == 'bar'
示例#15
0
 def test_get(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42")])
     assert nc_dict.get("bar") == None
     assert nc_dict.get("bar", "default_bar") == "default_bar"
     assert nc_dict.get("num") == "42"
     assert nc_dict.get("num", type_func=int) == 42
     assert nc_dict.get("foo") == "bar"
示例#16
0
 def test_get(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42')])
     assert nc_dict.get('bar') == None
     assert nc_dict.get('bar', 'default_bar') == 'default_bar'
     assert nc_dict.get('num') == '42'
     assert nc_dict.get('num', type_func=int) == 42
     assert nc_dict.get('foo') == 'bar'
示例#17
0
 def test_get(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42")])
     assert nc_dict.get("bar") == None
     assert nc_dict.get("bar", "default_bar") == "default_bar"
     assert nc_dict.get("num") == "42"
     assert nc_dict.get("num", type_func=int) == 42
     assert nc_dict.get("foo") == "bar"
示例#18
0
    def test_setitem(self):
        nc_dict = NoCaseMultiDict()
        nc_dict['foo'] = 'bar'
        assert nc_dict['foo'] == 'bar'
        nc_dict['foo'] = 'buz'
        assert nc_dict['foo'] == 'buz'
        nc_dict['bar'] = nc_dict['foo']
        assert nc_dict['bar'] == 'buz'

        nc_dict['bing'] = '1'
        nc_dict['bong'] = '2'
        nc_dict['bing'] = nc_dict['bong']
        assert nc_dict['bing'] == '2'
        assert nc_dict['bong'] == '2'
示例#19
0
    def test_setitem(self):
        nc_dict = NoCaseMultiDict()
        nc_dict["foo"] = "bar"
        assert nc_dict["foo"] == "bar"
        nc_dict["foo"] = "buz"
        assert nc_dict["foo"] == "buz"
        nc_dict["bar"] = nc_dict["foo"]
        assert nc_dict["bar"] == "buz"

        nc_dict["bing"] = "1"
        nc_dict["bong"] = "2"
        nc_dict["bing"] = nc_dict["bong"]
        assert nc_dict["bing"] == "2"
        assert nc_dict["bong"] == "2"
示例#20
0
 def test_multiple_sets(self):
     nc_dict = NoCaseMultiDict()
     nc_dict['foo'] = 'bar'
     assert nc_dict['FOO'] == 'bar'
     nc_dict['foo'] = 'baz'
     assert nc_dict['FOO'] == 'baz'
示例#21
0
 def test_get_all(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42"), ("foo", "biz")])
     assert nc_dict.get_all("bar") == []
     assert nc_dict.get_all("foo") == ["bar", "biz"]
     assert nc_dict.get_all("num") == ["42"]
示例#22
0
 def test_get_all(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42"),
                                ("foo", "biz")])
     assert nc_dict.get_all("bar") == []
     assert nc_dict.get_all("foo") == ["bar", "biz"]
     assert nc_dict.get_all("num") == ["42"]
示例#23
0
 def test_del(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42')])
     assert nc_dict['fOO'] == 'bar'
     del nc_dict['FOO']
     assert nc_dict.get('foo') == None
示例#24
0
 def test_set(self):
     nc_dict = NoCaseMultiDict()
     nc_dict.set('foo', 'bar')
     assert nc_dict.get_all('fOO') == ['bar']
     nc_dict.set('fOo', 'buzz', append=True)
     assert nc_dict.get_all('FOO') == ['bar', 'buzz']
     nc_dict.set('foO', 'bizz')
     assert nc_dict.get_all('FOO') == ['bizz']
     nc_dict.set('foO', ['ham', 'spam'], unpack=True)
     assert nc_dict.get_all('FOO') == ['ham', 'spam']
     nc_dict.set('FoO', ['egg', 'bacon'], append=True, unpack=True)
     assert nc_dict.get_all('FOo') == ['ham', 'spam', 'egg', 'bacon']
示例#25
0
 def test_get_all(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42'),
                                ('foo', 'biz')])
     assert nc_dict.get_all('bar') == []
     assert nc_dict.get_all('foo') == ['bar', 'biz']
     assert nc_dict.get_all('num') == ['42']
示例#26
0
 def test_set(self):
     nc_dict = NoCaseMultiDict()
     nc_dict.set("foo", "bar")
     assert nc_dict.get_all("fOO") == ["bar"]
     nc_dict.set("fOo", "buzz", append=True)
     assert nc_dict.get_all("FOO") == ["bar", "buzz"]
     nc_dict.set("foO", "bizz")
     assert nc_dict.get_all("FOO") == ["bizz"]
     nc_dict.set("foO", ["ham", "spam"], unpack=True)
     assert nc_dict.get_all("FOO") == ["ham", "spam"]
     nc_dict.set("FoO", ["egg", "bacon"], append=True, unpack=True)
     assert nc_dict.get_all("FOo") == ["ham", "spam", "egg", "bacon"]
示例#27
0
 def test_del(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42')])
     assert nc_dict['fOO'] == 'bar'
     del nc_dict['FOO']
     assert nc_dict.get('foo') == None
示例#28
0
 def test_del(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42")])
     assert nc_dict["fOO"] == "bar"
     del nc_dict["FOO"]
     assert nc_dict.get("foo") == None
示例#29
0
 def test_get_all(self):
     nc_dict = NoCaseMultiDict([('foo', 'bar'), ('num', '42'), ('foo', 'biz')])
     assert nc_dict.get_all('bar') == []
     assert nc_dict.get_all('foo') == ['bar', 'biz']
     assert nc_dict.get_all('num') == ['42']
示例#30
0
 def test_multiple_sets(self):
     nc_dict = NoCaseMultiDict()
     nc_dict["foo"] = "bar"
     assert nc_dict["FOO"] == "bar"
     nc_dict["foo"] = "baz"
     assert nc_dict["FOO"] == "baz"
示例#31
0
 def test_del(self):
     nc_dict = NoCaseMultiDict([("foo", "bar"), ("num", "42")])
     assert nc_dict["fOO"] == "bar"
     del nc_dict["FOO"]
     assert nc_dict.get("foo") == None
示例#32
0
 def test_set(self):
     nc_dict = NoCaseMultiDict()
     nc_dict.set('foo', 'bar')
     assert nc_dict.get_all('fOO') == ['bar']
     nc_dict.set('fOo', 'buzz', append=True)
     assert nc_dict.get_all('FOO') == ['bar', 'buzz']
     nc_dict.set('foO', 'bizz')
     assert nc_dict.get_all('FOO') == ['bizz']
     nc_dict.set('foO', ['ham', 'spam'], unpack=True)
     assert nc_dict.get_all('FOO') == ['ham', 'spam']
     nc_dict.set('FoO', ['egg', 'bacon'], append=True, unpack=True)
     assert nc_dict.get_all('FOo') == ['ham', 'spam', 'egg', 'bacon']
示例#33
0
 def test_set(self):
     nc_dict = NoCaseMultiDict()
     nc_dict.set("foo", "bar")
     assert nc_dict.get_all("fOO") == ["bar"]
     nc_dict.set("fOo", "buzz", append=True)
     assert nc_dict.get_all("FOO") == ["bar", "buzz"]
     nc_dict.set("foO", "bizz")
     assert nc_dict.get_all("FOO") == ["bizz"]
     nc_dict.set("foO", ["ham", "spam"], unpack=True)
     assert nc_dict.get_all("FOO") == ["ham", "spam"]
     nc_dict.set("FoO", ["egg", "bacon"], append=True, unpack=True)
     assert nc_dict.get_all("FOo") == ["ham", "spam", "egg", "bacon"]