| 150 | self.assertEqual(result, plain_text) |
| 151 | |
| 152 | def test_scrape_text_html(self): |
| 153 | # Create a Scraper instance |
| 154 | scraper = Scraper(print_error=MagicMock(), playwright_available=True) |
| 155 | |
| 156 | # Mock the scrape_with_playwright method |
| 157 | html_content = "<html><body><h1>Test</h1><p>This is HTML content.</p></body></html>" |
| 158 | scraper.scrape_with_playwright = MagicMock(return_value=(html_content, "text/html")) |
| 159 | |
| 160 | # Mock the html_to_markdown method |
| 161 | expected_markdown = "# Test\n\nThis is HTML content." |
| 162 | scraper.html_to_markdown = MagicMock(return_value=expected_markdown) |
| 163 | |
| 164 | # Call the scrape method |
| 165 | result = scraper.scrape("https://example.com") |
| 166 | |
| 167 | # Assert that the result is the expected markdown |
| 168 | self.assertEqual(result, expected_markdown) |
| 169 | |
| 170 | # Assert that html_to_markdown was called with the HTML content |
| 171 | scraper.html_to_markdown.assert_called_once_with(html_content) |
| 172 | |
| 173 | |
| 174 | if __name__ == "__main__": |