Skip to content

Commit

Permalink
Test symlinks not updated when no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
geigerzaehler committed Apr 5, 2024
1 parent 5d2b3d9 commit 9a4f33d
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,7 @@ def _symlink_view(self):
self.alt_config = self.config["alternatives"]["by-year"]

def test_add_move_remove_album(self, absolute=True):
"""Test the symlinks are created and deleted
* An album is added
* The path of the alternative collection is changed
* The query of the alternative collection is changed such that the
album does not match it anymore.
* The links are absolute
"""
"""Test the symlinks are created, updated and deleted"""
self.add_album(
artist="Michael Jackson",
album="Thriller",
Expand All @@ -134,42 +128,32 @@ def test_add_move_remove_album(self, absolute=True):

self.runcli("alt", "update", "by-year")

# Album added to collection
by_year_path = self.libdir / "by-year/1990/Thriller/track 1.mp3"
target_path = self.libdir / "Michael Jackson/Thriller/track 1.mp3"
assert_symlink(by_year_path, target_path, absolute)

# Collection path updated
self.alt_config["paths"]["default"] = "$original_year/$album/$title"
self.runcli("alt", "update", "by-year")

by_orig_year_path = self.libdir / "by-year/1982/Thriller/track 1.mp3"
assert_symlink(by_orig_year_path, target_path, absolute)

# No changes
out = self.runcli("alt", "update", "by-year")
assert out == ""

# Album removed from collection
self.alt_config["query"] = "some_field::foobar"
self.runcli("alt", "update", "by-year")

assert_is_not_file(by_orig_year_path)

def test_add_move_remove_album_absolute(self):
"""Test the absolute symlinks are created and deleted
* Config link type is absolute
* An album is added
* The path of the alternative collection is changed
* The query of the alternative collection is changed such that the
album does not match it anymore.
* The links are absolute
"""
self.alt_config["link_type"] = "absolute"
self.test_add_move_remove_album(absolute=True)

def test_add_move_remove_album_relative(self):
"""Test the relative symlinks are created and deleted
* Config link type is relative
* An album is added
* The path of the alternative collection is changed
* The query of the alternative collection is changed such that the
album does not match it anymore.
* The links are relative
"""
self.alt_config["link_type"] = "relative"
self.test_add_move_remove_album(absolute=False)

Expand Down

0 comments on commit 9a4f33d

Please sign in to comment.