test_summarization.py 937 B

12345678910111213141516171819202122232425262728
  1. """Unit tests for the summarization module."""
  2. from src.summarization import summarize
  3. def test_summarize_short_text() -> None:
  4. """Test summarization of short text."""
  5. text = "This is a short text. It has only two sentences."
  6. summary = summarize(text)
  7. assert summary == text
  8. def test_summarize_long_text() -> None:
  9. """Test summarization of long text."""
  10. text = (
  11. "This is a long text. It has many sentences. "
  12. "The summarization algorithm should pick the most important ones. "
  13. "The summary should be shorter than the original text. "
  14. "This is the fifth sentence. "
  15. "This is the sixth sentence. "
  16. "This is the seventh sentence. "
  17. "This is the eighth sentence. "
  18. "This is the ninth sentence. "
  19. "This is the tenth sentence."
  20. )
  21. summary = summarize(text)
  22. assert len(summary) < len(text)
  23. assert len(summary.split(". ")) <= 3