Beispiel #1
0
    def test_client_is_picklable(self):
        client = Client.GoogleAdsClient(
            {}, self.developer_token, endpoint=None, version=None,
        )

        try:
            pickled = pickle.dumps(client)
            pickle.loads(pickled)
        except:
            self.fail("Exception occurred when pickling GoogleAdsClient")
Beispiel #2
0
 def test_init_no_logging_config(self):
     """Should call logging.config.dictConfig if logging config exists."""
     with mock.patch(
             "logging.config.dictConfig"
     ) as mock_dictConfig, mock.patch.object(
             Client.oauth2,
             "get_installed_app_credentials") as mock_credentials:
         mock_credentials_instance = mock_credentials.return_value
         mock_credentials_instance.refresh_token = self.refresh_token
         mock_credentials_instance.client_id = self.client_id
         mock_credentials_instance.client_secret = self.client_secret
         Client.GoogleAdsClient(latest_version, mock_credentials_instance,
                                self.developer_token)
         mock_dictConfig.assert_not_called()
Beispiel #3
0
 def _create_test_client(self, endpoint=None, version=None):
     with mock.patch.object(
         Client.oauth2, "get_installed_app_credentials"
     ) as mock_credentials:
         mock_credentials_instance = mock_credentials.return_value
         mock_credentials_instance.refresh_token = self.refresh_token
         mock_credentials_instance.client_id = self.client_id
         mock_credentials_instance.client_secret = self.client_secret
         client = Client.GoogleAdsClient(
             mock_credentials_instance,
             self.developer_token,
             endpoint=endpoint,
             version=version,
         )
         return client
Beispiel #4
0
 def _create_test_client(self, **kwargs):
     with mock.patch.object(
             Client.oauth2,
             "get_installed_app_credentials") as mock_credentials:
         mock_credentials_instance = mock_credentials.return_value
         mock_credentials_instance.refresh_token = self.refresh_token
         mock_credentials_instance.client_id = self.client_id
         mock_credentials_instance.client_secret = self.client_secret
         client = Client.GoogleAdsClient(
             mock_credentials_instance,
             self.developer_token,
             endpoint=kwargs.get("endpoint"),
             version=kwargs.get("version"),
             http_proxy=kwargs.get("http_proxy"),
         )
         return client
Beispiel #5
0
 def test_init_with_logging_config(self):
     """Configured LoggingInterceptor should call logging.dictConfig."""
     config = {"test": True}
     with mock.patch(
         "logging.config.dictConfig"
     ) as mock_dictConfig, mock.patch.object(
         Client.oauth2, "get_installed_app_credentials"
     ) as mock_credentials:
         mock_credentials_instance = mock_credentials.return_value
         mock_credentials_instance.refresh_token = self.refresh_token
         mock_credentials_instance.client_id = self.client_id
         mock_credentials_instance.client_secret = self.client_secret
         Client.GoogleAdsClient(
             latest_version,
             mock_credentials_instance,
             self.developer_token,
             logging_config=config,
         )
         mock_dictConfig.assert_called_once_with(config)