Skip to content

Commit

Permalink
Add tests for cli query option
Browse files Browse the repository at this point in the history
  • Loading branch information
geigerzaehler committed Jul 12, 2024
1 parent bf36f89 commit f9add98
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,28 @@ def test_update_all(self, tmp_path: Path):
# Don’t update files on second run
assert self.runcli("alt", "update", "--all") == ""

def test_update_subset_query(self):
"""When a query is provided via the command line only update items in the
collection that also match that query."""

item_add = self.add_track(title="add", myexternal="true", foo="true")
item_dont_add = self.add_track(title="don't add", myexternal="true", foo="")
# Ensure that we don’t inadvertently add items that match the CLI query
# but not the collection query.
item_not_in_collection = self.add_track(title="not in collection", foo="true")

self.runcli("alt", "update", "myexternal", "--query", "foo:true")

item_add.load()
assert self.get_path(item_add).is_file()

item_dont_add.load()
assert not self.get_path(item_dont_add).is_file()

item_not_in_collection.load()
with pytest.raises(KeyError):
self.get_path(item_not_in_collection)


class TestExternalConvert(TestHelper):
"""Test alternatives with non-empty ``format`` option, i.e. transcoding
Expand Down

0 comments on commit f9add98

Please sign in to comment.