@@ -46,13 +46,57 @@ def test_constructor_explicit(self):
4646 target = "es"
4747 client_info = ClientInfo ()
4848 client = self ._make_one (
49- target_language = target , _http = http , client_info = client_info
49+ target_language = target ,
50+ _http = http ,
51+ client_info = client_info ,
52+ client_options = {"api_endpoint" : "https://foo-translation.googleapis.com" },
5053 )
5154 self .assertIsInstance (client ._connection , Connection )
5255 self .assertIsNone (client ._connection .credentials )
5356 self .assertIs (client ._connection .http , http )
5457 self .assertEqual (client .target_language , target )
5558 self .assertIs (client ._connection ._client_info , client_info )
59+ self .assertEqual (
60+ client ._connection .API_BASE_URL , "https://foo-translation.googleapis.com"
61+ )
62+
63+ def test_constructor_w_empty_client_options (self ):
64+ from google .cloud ._http import ClientInfo
65+ from google .api_core .client_options import ClientOptions
66+
67+ http = object ()
68+ target = "es"
69+ client_info = ClientInfo ()
70+ client_options = ClientOptions ()
71+ client = self ._make_one (
72+ target_language = target ,
73+ _http = http ,
74+ client_info = client_info ,
75+ client_options = client_options ,
76+ )
77+ self .assertEqual (
78+ client ._connection .API_BASE_URL , client ._connection .DEFAULT_API_ENDPOINT
79+ )
80+
81+ def test_constructor_w_client_options_object (self ):
82+ from google .cloud ._http import ClientInfo
83+ from google .api_core .client_options import ClientOptions
84+
85+ http = object ()
86+ target = "es"
87+ client_info = ClientInfo ()
88+ client_options = ClientOptions (
89+ api_endpoint = "https://foo-translation.googleapis.com"
90+ )
91+ client = self ._make_one (
92+ target_language = target ,
93+ _http = http ,
94+ client_info = client_info ,
95+ client_options = client_options ,
96+ )
97+ self .assertEqual (
98+ client ._connection .API_BASE_URL , "https://foo-translation.googleapis.com"
99+ )
56100
57101 def test_get_languages (self ):
58102 from google .cloud .translate_v2 .client import ENGLISH_ISO_639
0 commit comments