MBAPIHelper: introduce _make_inc_arg() to build inc parameter value

- it produces a more stable output (elements are sorted)
- it gets rid of empty elements (preventing a++b case)
- it accepts any iterable
- add a test for it

I also removed 2 useless conversion to tuple() (it can use a set() anyway)
This commit is contained in:
Laurent Monin
2023-06-09 08:50:34 +02:00
parent 9a0bedff20
commit 5395cbfc3d
4 changed files with 21 additions and 6 deletions

View File

@@ -98,7 +98,7 @@ class MBAPITest(PicardTestCase):
self.assertEqual(value, unencoded_query_args[argname])
def _test_inc_args(self, ws_function, arg_list):
self.assertInQuery(self.ws.get_url, 'inc', "+".join(arg_list))
self.assertInQuery(self.ws.get_url, 'inc', self.api._make_inc_arg(arg_list))
def test_get_release(self):
inc_args_list = ['test']
@@ -212,6 +212,11 @@ class MBAPITest(PicardTestCase):
with self.assertRaises(StopIteration):
next(generator)
def test_make_inc_arg(self):
result = self.api._make_inc_arg(['b', 'a', '', 1, (), 0])
expected = '1+a+b'
self.assertEqual(result, expected)
class AcoustdIdAPITest(PicardTestCase):