"""
Test suite for paroles_net_scraper package
"""
import sys
import os
import pytest
from unittest.mock import patch, Mock
# Add the parent directory to the path so we can import the scraper
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
# Import from the package
from paroles_net_scraper import get_song_lyrics
def test_get_song_lyrics_success():
"""Test successful lyrics retrieval with mocked response"""
# Mock HTML response with lyrics
mock_html = """
Paroles de la chanson Test Song par Test Artist
This is the first line of the song
This is the second line of the song
This is the third line of the song
"""
# Mock response object
mock_response = Mock()
mock_response.content = mock_html
mock_response.raise_for_status.return_value = None
# Mock BeautifulSoup parsing
with patch('paroles_net_scraper.paroles_net_scraper.requests.get', return_value=mock_response):
lyrics = get_song_lyrics("Test Artist", "Test Song")
assert "This is the first line of the song" in lyrics
assert "This is the second line of the song" in lyrics
assert "This is the third line of the song" in lyrics
# Check that the heading is not included
assert "Paroles de la chanson" not in lyrics
def test_get_song_lyrics_not_found():
"""Test handling of song not found"""
# Mock HTML response without lyrics div
mock_html = """