<commit_before>from unittest import TestCase

from modules.web_caller import get_google


class TestWebCaller(TestCase):
    """
    Tests for the `web_caller` module.
    """

    def test_get_google(self):
        """
        Calling `get_google` works as expected.
        """

        response = get_google()<commit_msg>Change get_google test to use mock<commit_after>from unittest import TestCase
from mock import NonCallableMock, patch

from modules.web_caller import get_google, GOOGLE_URL


class TestWebCaller(TestCase):
    """
    Tests for the `web_caller` module.
    """

    @patch('modules.web_caller.requests.get')
    def test_get_google(self, get):
        """
        Calling `get_google` works as expected.
        """

        # Create a mock response
        mock_response = NonCallableMock(
            status_code=200,
        )
        # Assign the mock response as the requests.get return value
        get.return_value = mock_response

        # Call the function
        response = get_google()

        # Check that requests.get was called with the expected URL
        get.assert_called_once_with(GOOGLE_URL)

        # Check that the mock response is returned
        self.assertIs(mock_response, response)

        # Check that the mocked response.status_code is as expected
{'fraction_non_alphanumeric': 0.07345065034429993, 'fraction_numerical': 0.0022953328232593728, 'mean_word_length': 2.6741573033707864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '482894', 'n_tokens_mistral': 374, 'n_tokens_neox': 358, 'n_words': 108}