Пример #1
0
 def test_query_all_one(self):
     s = Query('a=1')
     self.assertEqual(s.getall('a'), ['1'])
Пример #2
0
 def test_query_all_none(self):
     s = Query('a=1')
     self.assertEqual(s.getall('c'), [])
Пример #3
0
 def test_query_string_values(self):
     s = Query('a=1&a=2')
     self.assertEqual(s['a'], '1')
Пример #4
0
 def test_query_all_values(self):
     s = Query('a=1&a=2')
     self.assertEqual(s.getall('a'), ['1', '2'])
Пример #5
0
 def test_query_values_escaped(self):
     s = Query('a=1%2f0&a=2%2f3')
     self.assertEqual(s.getall('a'), ['1/0', '2/3'])
Пример #6
0
 def test_query_string_empty(self):
     s = Query('a=')
     self.assertEqual(s['a'], '')
Пример #7
0
 def test_query_label_escaped(self):
     s = Query('a%2fb=1')
     self.assertEqual(s['a/b'], '1')
Пример #8
0
 def test_empty(self):
     s = Query('')
     self.assertFalse(bool(s))
     self.assertEqual(len(s), 0)
     self.assertEqual(s, {})
Пример #9
0
 def test_query_string_nothing(self):
     s = Query('a=1')
     self.assertRaises(KeyError, lambda: s['b'])
Пример #10
0
 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)
Пример #11
0
 def test_contains(self):
     self.assertTrue('a' in Query('a'))
     self.assertTrue('a' in Query('a='))
     self.assertTrue('a' in Query('a=b'))
Пример #12
0
 def test_truthiness(self):
     s = Query('a=1')
     self.assertTrue(bool(s))
Пример #13
0
 def test_empty_dict(self):
     s = Query({})
     self.assertEqual(s, {})
Пример #14
0
 def test_iterable(self):
     s = Query([
         ('a', 'abc'),
         ('a', 'def'),
     ])
     self.assertEqual(s.getall('a'), ['abc', 'def'])
Пример #15
0
 def test_query_value_escaped(self):
     s = Query('a=1%2f0')
     self.assertEqual(s['a'], '1/0')
Пример #16
0
 def test_copy(self):
     s = Query({'a': 'abc'})
     s = Query(s)
     self.assertEqual(s.getall('a'), ['abc'])
Пример #17
0
 def test_query_string_none(self):
     s = Query('a')
     self.assertEqual(s['a'], None)