-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use fuzz.ratio instead of partial_ratio for fuzzy matching add unit test for fuzzy matching make fuzzy matching the only matching algo * remove OBE test and commented out code * update readme
- Loading branch information
Showing
6 changed files
with
156 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import ytmusicapi | ||
from ytmusic_deleter import uploads | ||
|
||
|
||
class TestUploads: | ||
def test_fuzzy_matching(self, yt_browser: ytmusicapi.YTMusic, fuzzy_test_data): | ||
score_cutoff = 85 | ||
num_correct = 0 | ||
for group in fuzzy_test_data: | ||
upload_artist = group["upload_artist"] | ||
upload_title = group["upload_title"] | ||
match = uploads.add_album_to_library(upload_artist, upload_title, yt_browser, score_cutoff) | ||
if match is None: | ||
if group["expected_artist"] is None and group["expected_title"] is None: | ||
print("Correctly failed to find match") | ||
num_correct += 1 | ||
else: | ||
print("Failed to find any match when one was expected") | ||
print(f"\tExpected: {group['expected_artist']} - {group['expected_title']}") | ||
elif not group["expected_artist"] and not group["expected_title"]: | ||
print("Found match when none was expected") | ||
print(f"\tFound: {match['artist']} - {match['title']}") | ||
elif ( | ||
match["artist"].lower() == group["expected_artist"].lower() | ||
and match["title"].lower() == group["expected_title"].lower() | ||
): | ||
print("Correctly found match") | ||
num_correct += 1 | ||
else: | ||
print("Found incorrect match") | ||
print(f"\tExpected: {group['expected_artist']} - {group['expected_title']}") | ||
print(f"\tActual: {match['artist']} - {match['title']}") | ||
assert num_correct == len(fuzzy_test_data), f"Only {num_correct} out of {len(fuzzy_test_data)} were correct" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters