From f5ff33a92612c95dc38aed7cce30898e9887b17a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Feb 2025 20:49:00 +0530 Subject: [PATCH] Add a test for single value tag mapping --- src/calibre/ebooks/metadata/tag_mapper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/metadata/tag_mapper.py b/src/calibre/ebooks/metadata/tag_mapper.py index bbe4e455bd..651877ab81 100644 --- a/src/calibre/ebooks/metadata/tag_mapper.py +++ b/src/calibre/ebooks/metadata/tag_mapper.py @@ -151,14 +151,14 @@ def find_tests(): ans['replace'] = replace return ans - def run(rules, tags, expected): + def run(rules, tags, expected, sep=','): if isinstance(rules, dict): rules = [rules] if isinstance(tags, str): - tags = [x.strip() for x in tags.split(',')] + tags = [x.strip() for x in tags.split(sep)] if sep else [tags] if isinstance(expected, str): - expected = [x.strip() for x in expected.split(',')] - ans = map_tags(tags, rules) + expected = [x.strip() for x in expected.split(sep)] if sep else [expected] + ans = map_tags(tags, rules, sep) self.assertEqual(ans, expected) run(rule('capitalize', 't1,t2'), 't1,x1', 'T1,x1') @@ -180,6 +180,7 @@ def find_tests(): run(rule('split', '/', '/', 'has'), '/a/', 'a') run(rule('split', 'a,b', '/'), 'a,b', 'a,b') run(rule('split', 'a b', ' ', 'has'), 'a b', 'a,b') + run(rule('upper', 'a, b, c'), 'a, b, c', 'A, B, C', sep='') return unittest.defaultTestLoader.loadTestsFromTestCase(TestTagMapper)