File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44import hashlib
55import hmac
6+ import warnings
67
78import six
89from six .moves .urllib .parse import quote , urlparse
@@ -51,6 +52,23 @@ def sort_params(param_dict):
5152
5253 This function should probably not be part of the public API, and thus will
5354 be deprecated in a future release to be replaced with a internal function.
55+
56+ .. deprecated:: 5.0.0
57+
58+ Use :func:`laterpay.signing.normalise_param_structure` instead.
59+ """
60+ warnings .warn (
61+ 'laterpay.signing.sort_params is deprecated and will be removed in '
62+ 'future versions. Use laterpay.signing.normalise_param_structure '
63+ 'instead.' ,
64+ DeprecationWarning
65+ )
66+ return _sort_params (param_dict )
67+
68+
69+ def _sort_params (param_dict ):
70+ """
71+ Sort a key-value mapping with non-unique keys.
5472 """
5573 param_list = []
5674 for name , value_list in six .iteritems (param_dict ):
Original file line number Diff line number Diff line change 44
55import hashlib
66import unittest
7+ import warnings
78
89import furl
910
@@ -239,14 +240,24 @@ def test_sort_params(self):
239240 'key2' : ['value22' , 'value21' ],
240241 'key3' : ('value32' , 'value31' ),
241242 }
242- self .assertEqual (signing .sort_params (params ), [
243+ self .assertEqual (signing ._sort_params (params ), [
243244 ('key1' , 'value1' ),
244245 ('key2' , 'value21' ),
245246 ('key2' , 'value22' ),
246247 ('key3' , 'value31' ),
247248 ('key3' , 'value32' ),
248249 ])
249250
251+ def test_sort_params_public_deprecation (self ):
252+ with warnings .catch_warnings (record = True ) as w :
253+ warnings .simplefilter ("always" )
254+ signing .sort_params ({})
255+ self .assertEqual (
256+ w [0 ].message .args [0 ],
257+ 'laterpay.signing.sort_params is deprecated and will be removed in future '
258+ 'versions. Use laterpay.signing.normalise_param_structure instead.'
259+ )
260+
250261
251262if __name__ == '__main__' :
252263 unittest .main ()
You can’t perform that action at this time.
0 commit comments