- def get_ids(params):
- return [int(v['id']) for v in get_downloaded_info_dicts(params)]
-
- result = get_ids({})
- self.assertEqual(result, [1, 2, 3, 4])
-
- result = get_ids({'playlistend': 10})
- self.assertEqual(result, [1, 2, 3, 4])
-
- result = get_ids({'playlistend': 2})
- self.assertEqual(result, [1, 2])
-
- result = get_ids({'playliststart': 10})
- self.assertEqual(result, [])
-
- result = get_ids({'playliststart': 2})
- self.assertEqual(result, [2, 3, 4])
-
- result = get_ids({'playlist_items': '2-4'})
- self.assertEqual(result, [2, 3, 4])
-
- result = get_ids({'playlist_items': '2,4'})
- self.assertEqual(result, [2, 4])
-
- result = get_ids({'playlist_items': '10'})
- self.assertEqual(result, [])
-
- result = get_ids({'playlist_items': '3-10'})
- self.assertEqual(result, [3, 4])
-
- result = get_ids({'playlist_items': '2-4,3-4,3'})
- self.assertEqual(result, [2, 3, 4])
+ def test_selection(params, expected_ids):
+ results = [
+ (v['playlist_autonumber'] - 1, (int(v['id']), v['playlist_index']))
+ for v in get_downloaded_info_dicts(params)]
+ self.assertEqual(results, list(enumerate(zip(expected_ids, expected_ids))))
+
+ test_selection({}, [1, 2, 3, 4])
+ test_selection({'playlistend': 10}, [1, 2, 3, 4])
+ test_selection({'playlistend': 2}, [1, 2])
+ test_selection({'playliststart': 10}, [])
+ test_selection({'playliststart': 2}, [2, 3, 4])
+ test_selection({'playlist_items': '2-4'}, [2, 3, 4])
+ test_selection({'playlist_items': '2,4'}, [2, 4])
+ test_selection({'playlist_items': '10'}, [])