""" Unit tests for ContentGenerator service """ import pytest from src.generation.service import ContentGenerator def test_count_words_simple(): """Test word count on simple text""" generator = ContentGenerator(None, None, None, None) html = "
This is a test with five words
" count = generator.count_words(html) assert count == 7 def test_count_words_with_headings(): """Test word count with HTML headings""" generator = ContentGenerator(None, None, None, None) html = """This is a paragraph with some words.
Another paragraph here.
""" count = generator.count_words(html) assert count > 10 def test_count_words_strips_html_tags(): """Test that HTML tags are stripped before counting""" generator = ContentGenerator(None, None, None, None) html = "Hello world this is a test
" count = generator.count_words(html) assert count == 6 def test_validate_word_count_within_range(): """Test validation when word count is within range""" generator = ContentGenerator(None, None, None, None) content = "" + " ".join(["word"] * 100) + "
" is_valid, count = generator.validate_word_count(content, 50, 150) assert is_valid is True assert count == 100 def test_validate_word_count_below_minimum(): """Test validation when word count is below minimum""" generator = ContentGenerator(None, None, None, None) content = "" + " ".join(["word"] * 30) + "
" is_valid, count = generator.validate_word_count(content, 50, 150) assert is_valid is False assert count == 30 def test_validate_word_count_above_maximum(): """Test validation when word count is above maximum""" generator = ContentGenerator(None, None, None, None) content = "" + " ".join(["word"] * 200) + "
" is_valid, count = generator.validate_word_count(content, 50, 150) assert is_valid is False assert count == 200 def test_count_words_empty_content(): """Test word count on empty content""" generator = ContentGenerator(None, None, None, None) count = generator.count_words("") assert count == 0 def test_count_words_only_tags(): """Test word count on content with only HTML tags""" generator = ContentGenerator(None, None, None, None) html = "