def test_query_params_sorted_order(self): self.assertEqual( generate_base_string_query(dict(b=[8, 2, 4], a=1), {}), b("a=1&b=2&b=4&b=8")) qs = generate_base_string_query( dict(a=5, b=6, c=["w", "a", "t", "e", "r"]), {}) self.assertEqual(qs, b("a=5&b=6&c=a&c=e&c=r&c=t&c=w"))
def test_simplegeo_example(self): self.assertNotEqual( generate_base_string_query(self.simplegeo_example_url_query_params, self.simplegeo_example_oauth_params), self.simplegeo_example_wrong_order_query_string) self.assertEqual( generate_base_string_query(self.simplegeo_example_url_query_params, self.simplegeo_example_oauth_params), self.simplegeo_example_correct_query_string)
def test_oauth_signature_and_realm_are_excluded_properly(self): qs = generate_base_string_query({ OAUTH_PARAM_SIGNATURE: "something" }, self.specification_example_oauth_params ) self.assertTrue(b("oauth_signature=") not in qs) self.assertTrue(b("realm=") not in qs) self.assertTrue( generate_base_string_query(dict(realm="something"), dict()), b("realm=something") )
def test_no_query_params_returns_empty_string(self): self.assertEqual(generate_base_string_query({}, {}), b("")) self.assertEqual(generate_base_string_query(None, None), b(""))
def test_non_string_single_value(self): self.assertEqual(generate_base_string_query(dict(a=5), None), b("a=5")) self.assertEqual( generate_base_string_query(dict(aFlag=True, bFlag=False), None), b("aFlag=True&bFlag=False") )
def test_multiple_values(self): self.assertEqual( generate_base_string_query(dict(a=[5, 8]), {}), b("a=5&a=8") )
def test_oauth_specification_example(self): self.assertEqual(generate_base_string_query( self.specification_url_query_params, self.specification_example_oauth_params), self.specification_example_query_string)