def test_query_all_one(self): s = Query('a=1') self.assertEqual(s.getall('a'), ['1'])
def test_query_all_none(self): s = Query('a=1') self.assertEqual(s.getall('c'), [])
def test_query_string_values(self): s = Query('a=1&a=2') self.assertEqual(s['a'], '1')
def test_query_all_values(self): s = Query('a=1&a=2') self.assertEqual(s.getall('a'), ['1', '2'])
def test_query_values_escaped(self): s = Query('a=1%2f0&a=2%2f3') self.assertEqual(s.getall('a'), ['1/0', '2/3'])
def test_query_string_empty(self): s = Query('a=') self.assertEqual(s['a'], '')
def test_query_label_escaped(self): s = Query('a%2fb=1') self.assertEqual(s['a/b'], '1')
def test_empty(self): s = Query('') self.assertFalse(bool(s)) self.assertEqual(len(s), 0) self.assertEqual(s, {})
def test_query_string_nothing(self): s = Query('a=1') self.assertRaises(KeyError, lambda: s['b'])
def test_query_label_escaped_contains(self): s = Query('a%2fb&a%40b') self.assertTrue('a/b' in s) self.assertTrue('a@b' in s)
def test_contains(self): self.assertTrue('a' in Query('a')) self.assertTrue('a' in Query('a=')) self.assertTrue('a' in Query('a=b'))
def test_truthiness(self): s = Query('a=1') self.assertTrue(bool(s))
def test_empty_dict(self): s = Query({}) self.assertEqual(s, {})
def test_iterable(self): s = Query([ ('a', 'abc'), ('a', 'def'), ]) self.assertEqual(s.getall('a'), ['abc', 'def'])
def test_query_value_escaped(self): s = Query('a=1%2f0') self.assertEqual(s['a'], '1/0')
def test_copy(self): s = Query({'a': 'abc'}) s = Query(s) self.assertEqual(s.getall('a'), ['abc'])
def test_query_string_none(self): s = Query('a') self.assertEqual(s['a'], None)