diff --git a/test/test_ui.py b/test/test_ui.py index dd24fce1a1..a50f389bad 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -22,6 +22,7 @@ import platform import sys import unittest +import textwrap from unittest.mock import patch, Mock from test import _common @@ -729,6 +730,41 @@ def test_quiet_timid_disallowed(self): self.assertRaises(ui.UserError, commands.import_files, None, [], None) + def test_parse_paths_from_logfile(self): + if os.path.__name__ == 'ntpath': + logfile_content = """ + import started Wed Jun 15 23:08:26 2022 + asis C:\\music\\Beatles, The\\The Beatles; C:\\music\\Beatles, The\\The Beatles\\CD 01; C:\\music\\Beatles, The\\The Beatles\\CD 02 + duplicate-replace C:\\music\\Bill Evans\\Trio '65 + skip C:\\music\\Michael Jackson\\Bad + skip C:\\music\\Soulwax\\Any Minute Now + """ + expected_paths = [ + "C:\\music\\Beatles, The\\The Beatles", + "C:\\music\\Michael Jackson\\Bad", + "C:\\music\\Soulwax\\Any Minute Now", + ] + else: + logfile_content = """ + import started Wed Jun 15 23:08:26 2022 + asis /music/Beatles, The/The Beatles; /music/Beatles, The/The Beatles/CD 01; /music/Beatles, The/The Beatles/CD 02 + duplicate-replace /music/Bill Evans/Trio '65 + skip /music/Michael Jackson/Bad + skip /music/Soulwax/Any Minute Now + """ + expected_paths = [ + "/music/Beatles, The/The Beatles", + "/music/Michael Jackson/Bad", + "/music/Soulwax/Any Minute Now", + ] + + logfile = os.path.join(self.temp_dir, b"logfile.log") + with open(logfile, mode="w") as fp: + fp.write(textwrap.dedent(logfile_content).strip("\n")) + actual_paths = list(commands._paths_from_logfile(logfile)) + + self.assertEqual(actual_paths, expected_paths) + @_common.slow_test() class ConfigTest(unittest.TestCase, TestHelper, _common.Assertions):