from unittest.mock import MagicMock, patch from app.app import count_words @patch("app.app.requests") def test_count_words(mock_requests): mock_response = MagicMock() mock_response.text = "example word count split" mock_requests.get.return_value = mock_response wc = count_words("http://anyurl.com") assert wc == 4 # TODO add test coverage for failure