mirror of
				https://github.com/KevinMidboe/spotify-downloader.git
				synced 2025-10-29 18:00:15 +00:00 
			
		
		
		
	* Monkeypatch fetch user and use pytest.tempdir * Cover spotify_tools.grab_album() * Cover avconv conversion * Cover grab_single() * Reduce code repetition * Move grab_playlist() to spotify_tools.py * Move Spotify specific functions to spotify_tools.py * Refactoring * Return track list from write_tracks() * Fix tests * Cover more cases in generate_youtube_url() * Test for unavailable audio streams * Test for filename without spaces * handle.py 100% coverage * Improve config tests * Speed up tests * Install avconv and libfdk-aac * Some cleaning * FFmpeg with libfdk-aac, libopus * Some refactoring * Convert tmpdir to string * Cover YouTube title when downloading from list * Explicitly cover some internals.py functions
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from core import spotify_tools
 | |
| from core import const
 | |
| 
 | |
| import spotdl
 | |
| 
 | |
| import builtins
 | |
| import os
 | |
| 
 | |
| 
 | |
| def test_user_playlists(tmpdir, monkeypatch):
 | |
|     expect_tracks = 14
 | |
|     text_file = os.path.join(str(tmpdir), 'test_us.txt')
 | |
|     monkeypatch.setattr('builtins.input', lambda x: 1)
 | |
|     spotify_tools.write_user_playlist('alex', text_file)
 | |
|     with open(text_file, 'r') as tin:
 | |
|         tracks = len(tin.readlines())
 | |
|     assert tracks == expect_tracks
 | |
| 
 | |
| 
 | |
| def test_playlist(tmpdir):
 | |
|     expect_tracks = 14
 | |
|     text_file = os.path.join(str(tmpdir), 'test_pl.txt')
 | |
|     spotify_tools.write_playlist('https://open.spotify.com/user/alex/playlist/0iWOVoumWlkXIrrBTSJmN8', text_file)
 | |
|     with open(text_file, 'r') as tin:
 | |
|         tracks = len(tin.readlines())
 | |
|     assert tracks == expect_tracks
 | |
| 
 | |
| 
 | |
| def test_album(tmpdir):
 | |
|     expect_tracks = 15
 | |
|     global text_file
 | |
|     text_file = os.path.join(str(tmpdir), 'test_al.txt')
 | |
|     spotify_tools.write_album('https://open.spotify.com/album/499J8bIsEnU7DSrosFDJJg', text_file)
 | |
|     with open(text_file, 'r') as tin:
 | |
|         tracks = len(tin.readlines())
 | |
|     assert tracks == expect_tracks
 | |
| 
 | |
| 
 | |
| def test_trim():
 | |
|     with open(text_file, 'r') as track_file:
 | |
|         tracks = track_file.readlines()
 | |
| 
 | |
|     expect_number = len(tracks) - 1
 | |
|     expect_track = tracks[0]
 | |
|     track = spotdl.internals.trim_song(text_file)
 | |
| 
 | |
|     with open(text_file, 'r') as track_file:
 | |
|         number = len(track_file.readlines())
 | |
| 
 | |
|     assert (expect_number == number and expect_track == track)
 |