Example #1
0
    def test_get_headers_with_user_specific_headers(self):
        translator = GoogleTranslator()

        # This should overwrite the default Host header
        translator._user_specific_headers = {"Host": "test.com"}

        expected_headers = dict(translator._default_headers)
        expected_headers["Host"] = "test.com"

        self.assertListEqual(translator._get_headers(),
                             expected_headers.items())
Example #2
0
    def test_get_headers_with_user_specific_headers_and_uaselector(self):
        mock_ua_selector = mock.MagicMock()
        translator = GoogleTranslator(ua_selector=mock_ua_selector)

        # This should overwrite both the default user-agent and the uaselector
        translator._user_specific_headers = {"User-Agent": "user_spec_ua"}

        expected_headers = dict(translator._default_headers)
        expected_headers["User-Agent"] = "user_spec_ua"

        self.assertListEqual(translator._get_headers(),
                             expected_headers.items())