Skip to content

Commit

Permalink
test(import): Add test for _paths_from_logfile method
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Jun 27, 2022
1 parent 6d74ffb commit 3e37d01
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,40 @@ 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\n"
"asis C:\\music\\Beatles, The\\The Beatles; C:\\music\\Beatles, The\\The Beatles\\CD 01; C:\\music\\Beatles, The\\The Beatles\\CD 02\n" # noqa: E501
"duplicate-replace C:\\music\\Bill Evans\\Trio '65\n"
"skip C:\\music\\Michael Jackson\\Bad\n"
"skip C:\\music\\Soulwax\\Any Minute Now\n"
)
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\n"
"asis /music/Beatles, The/The Beatles; /music/Beatles, The/The Beatles/CD 01; /music/Beatles, The/The Beatles/CD 02\n" # noqa: E501
"duplicate-replace /music/Bill Evans/Trio '65\n"
"skip /music/Michael Jackson/Bad\n"
"skip /music/Soulwax/Any Minute Now\n"
)
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(logfile_content)
actual_paths = list(commands._paths_from_logfile(logfile))
self.assertEqual(actual_paths, expected_paths)


@_common.slow_test()
class ConfigTest(unittest.TestCase, TestHelper, _common.Assertions):
Expand Down

0 comments on commit 3e37d01

Please sign in to comment.