def test_getall_default_value_for_missing_key(self): d = ice.MultiDict() self.assertEqual(d.getall('a', 'foo'), 'foo')
def test_getall_for_multiple_value(self): d = ice.MultiDict() d['a'] = 'foo' d['a'] = 'bar' self.assertEqual(d.getall('a'), ['foo', 'bar'])
def test_getall_for_missing_key(self): d = ice.MultiDict() self.assertEqual(d.getall('a'), [])
def test_missing_key(self): d = ice.MultiDict() with self.assertRaises(KeyError) as cm: d['foo'] self.assertEqual(str(cm.exception), "'foo'")
def test_getall_for_single_value(self): d = ice.MultiDict() d['a'] = 'foo' self.assertEqual(d.getall('a'), ['foo'])
def test_len(self): d = ice.MultiDict() d['a'] = 'foo' d['b'] = 'bar' d['b'] = 'baz' self.assertEqual(len(d), 2)
def test_getitem_for_multiple_values(self): d = ice.MultiDict() d['a'] = 'foo' d['a'] = 'bar' self.assertEqual(d['a'], 'bar')
def test_get(self): d = ice.MultiDict() d['a'] = 'foo' self.assertEqual(d.get('a'), 'foo') self.assertEqual(d.get('b', 'bar'), 'bar')
def test_getitem(self): d = ice.MultiDict() d['a'] = 'foo' self.assertEqual(d['a'], 'foo')
def test_setitem(self): d = ice.MultiDict() d['a'] = 'foo' d['b'] = 'bar' d['b'] = 'baz' self.assertEqual(d.data, {'a': ['foo'], 'b': ['bar', 'baz']})