'Test QueryDict with one key/value pair'

def test_single_key_value(self):

    q = QueryDict('foo=bar')
    self.assertEqual(q['foo'], 'bar')
    self.assertRaises(KeyError, q.__getitem__, 'bar')
    self.assertRaises(AttributeError, q.__setitem__, 'something', 'bar')
    self.assertEqual(q.get('foo', 'default'), 'bar')
    self.assertEqual(q.get('bar', 'default'), 'default')
    self.assertEqual(q.getlist('foo'), ['bar'])
    self.assertEqual(q.getlist('bar'), [])
    self.assertRaises(AttributeError, q.setlist, 'foo', ['bar'])
    self.assertRaises(AttributeError, q.appendlist, 'foo', ['bar'])
    self.assertTrue(q.has_key('foo'))
    self.assertTrue(('foo' in q))
    self.assertFalse(q.has_key('bar'))
    self.assertFalse(('bar' in q))
    self.assertEqual(q.items(), [(u'foo', u'bar')])
    self.assertEqual(q.lists(), [(u'foo', [u'bar'])])
    self.assertEqual(q.keys(), ['foo'])
    self.assertEqual(q.values(), ['bar'])
    self.assertEqual(len(q), 1)
    self.assertRaises(AttributeError, q.update, {'foo': 'bar'})
    self.assertRaises(AttributeError, q.pop, 'foo')
    self.assertRaises(AttributeError, q.popitem)
    self.assertRaises(AttributeError, q.clear)
    self.assertRaises(AttributeError, q.setdefault, 'foo', 'bar')
    self.assertEqual(q.urlencode(), 'foo=bar')
