Commit graph

35 commits

Author SHA1 Message Date
Šarūnas Nejus
88011a7c65
Show genre change using show_model_changes 2025-10-15 11:14:26 +01:00
Šarūnas Nejus
c2d5c1f17c
Update test 2025-10-15 09:55:51 +01:00
J0J0 Todos
654c14490e
lastgenre: Refactor test_pretend to pytest 2025-10-15 09:54:41 +01:00
J0J0 Todos
d617e67199
lastgenre: Fix test_pretend_option
only one arg is passed to the info log anymore.
2025-10-15 09:52:32 +01:00
J0J0 Todos
2e307b519a lastgenre: Also mock try_write in test_pretend..
and add and original genre instead empty string (clarify intention of
test / readability). Remove not really necessary assert items checks.
2025-09-21 07:07:14 +02:00
Alok Saboo
9b1537f226 Add test for --pretend option in LastGenrePlugin to skip library updates 2025-09-21 07:07:14 +02:00
J0J0 Todos
f85ba7ab3b lastgenre: Fix test_get_genre loading whitelist
- The default whitelist files were not loaded properly (at least in
  local test environments, not sure about CI yet...anyway...)
2025-08-24 09:20:36 +02:00
J0J0 Todos
7f7b900f1b lastgenre: Test canonicalization
- Test non-whitelisted genres resolving "up" in the tree.
- Test whitelisted original and whitelisted new genre resolving "up"
- Test non-whitelisted original genre resolving "up" (and deduplication
  works)
2025-08-24 09:20:36 +02:00
Šarūnas Nejus
5900282093
Use BeetsTestCase for lastgenre tests, re-use the defined config 2025-05-26 13:05:40 +01:00
Šarūnas Nejus
c9f98fca55
Use unittest.TestCase for tests that don't require the dir setup 2025-05-26 12:40:38 +01:00
J0J0 Todos
eb83491788 lastgenre: Fix "original fallback" conditions
This was not thought through clearly before. It now behaves as follows
which I suppose is least surprising to a user:

- force is on, keep_existing is on, but the whitelist is DISABLED
- no stage found anything on last.fm
- fall back to the original genre

If in this example the whitelist would be ENABLED, the behaviour
changes: Only if the existing genre passes the whitelist test the
original is kept.
2025-04-09 22:52:07 +02:00
J0J0 Todos
de9020055d lastgenre: Add test ensuring next stage is hit
If no album was found the next stage (artist) should be entered, the
original genre kicked out (not whitelisted) and artist genre accepted.
The log message is slightly misleading since it tried to keep existing
genres but they were not whitelisted, thus kicked out. This is expected.
2025-04-09 22:52:07 +02:00
J0J0 Todos
e20cf7f20b lastgenre: Rework combine, stringify, count reduction
- Rename method from _combine_genres() to _combine_resolve_and_log() to
  make clear that it not only combines new and old genres but also
  resolves them (which in this plugin's wording means "do the magic" of
  canonicalizationm, whitelist checking and reducing to a configured
  genre count).

- Clarify in _resolve docstring that a possible outcome might be all
  genres being removed.

- Add an additional log message telling which existing genres are taken
  into account BEFORE "the magic happens".

- Rename _to_delimited_genre_string() to _format_and_stringify()

- Move count reduction logic to _resolve_genres()

- Fix and rename a test
2025-04-09 22:52:07 +02:00
J0J0 Todos
5d9d8840ae Fix a lastgenre test 2025-01-22 18:20:41 +01:00
J0J0 Todos
261379f395 Add test_get_genre case proving no-force keeps any
because _get_existing_genres does not rely on configured separator.
2025-01-22 18:07:43 +01:00
J0J0 Todos
34b9021772 Fix test_get_genrer - configure first
otherwise self.whitelist is "set up" before the test cases config is
set.
2025-01-22 18:07:43 +01:00
J0J0 Todos
1219b43af4 Fix a test: no-force always early returns 2025-01-21 17:48:21 +01:00
J0J0 Todos
d703a7f712 Fix tests for log-label changes 2025-01-21 17:14:15 +01:00
J0J0 Todos
6e3f5b3127 Fix type hints, Refactor existing genres method
- Rename method _dedup_genre, since it's only used for
  finalizing/polishing existing genres.
- Return separator-delimited string already.
- Decide on not passing "separator" to methods, it's a config
  setting available throughout the plugin. Assign to variable where
  useful for readability though.
- In the force branch, remove re-assigning keep_genres to empty list.
- Fix a test. Existing genres are "polished" now, which means:
  configured title_case is applied.
- Fix/add type hints on all touched and new methods
2025-01-21 17:04:03 +01:00
J0J0 Todos
6cd000750a _resolve_genre as list tests, add test_to_delimited_string
- Adapt tests to _resolve_genres returning a list with not yet formatted genres.
- Rename and adapt test_count -> test_to_delimited_string. Note that the
  new function does not apply whitelist, prefer anything. It just cuts
  to count and formats!
2025-01-21 17:04:02 +01:00
J0J0 Todos
dd3a74ca4d Fix lastgenre limit to count test
- No idea where a missing separator (which is default) could
  happen...just set it explicitely.
- Since we now refactored fetch_genre to returning a list we can add
  mock multiple fetched gernes easier.
2025-01-21 17:04:02 +01:00
J0J0 Todos
b4590ec3e0 Fix/add lastgenre fallback tests 2025-01-21 17:04:02 +01:00
J0J0 Todos
50e2619ed2 Refactor lastgenre mocked fetchers return list 2025-01-21 17:04:02 +01:00
J0J0 Todos
3e452e7b76 lastgenre test _get_genre for renamed keep_existing
and decide to use the original default whitelist instead of trying to
mock it. Some of the existing tests do it that way as well.
2025-01-21 17:04:02 +01:00
J0J0 Todos
1c14574e85 Add lastgenre testcase with unicode \0 separator 2025-01-21 17:04:02 +01:00
J0J0 Todos
a434ecfe7b Refactor _get_genre test to parametrized pytest 2025-01-21 17:04:02 +01:00
J0J0 Todos
70d641c556 Experiment with test_lastgenre 2025-01-21 17:04:02 +01:00
Šarūnas Nejus
f9359df0d1
Replace assertNotEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
9a05d27acf
Replace assertEqual 2024-08-12 08:43:42 +01:00
Šarūnas Nejus
fcff5d72af
Remove def suite TestLoader definitions 2024-07-28 18:58:51 +01:00
Šarūnas Nejus
2d5fd907c3
Remove redundant setup_beets and teardown_beets instructions 2024-07-28 18:58:34 +01:00
Šarūnas Nejus
6c1e26acc9
Replace unittest.TestCase, TestHelper by BeetsTestCase 2024-07-28 18:58:34 +01:00
Lars Kruse
508d28f66b tests: move reusable test-related modules into the beets package
External Python packages interfacing beets may want to use an in-memory
beets library instance for testing beets-related code.
The `TestHelper` class is very helpful for this purpose.
Previously `TestHelper` was located in the `test/` directory.
Now it is part of `beets` itself (`beets.test.helper.TestHelper`) and
can be easily imported.
2024-01-15 19:40:57 +01:00
Serene-Arc
a6e5201ff3 Apply formatting tools to all files
This is 'the big one', which touches every file so that it all conforms
to the given standard.
2023-10-22 09:53:18 +10:00
Serene-Arc
84c0ab6857 Correctly refactor tests 2023-10-17 19:39:03 +10:00
Renamed from test/plugin/test_lastgenre.py (Browse further)