Skip to content

Commit 25a740a

Browse files
chore: remove unreachable code (#997)
1 parent 18bc377 commit 25a740a

File tree

3 files changed

+2
-85
lines changed

3 files changed

+2
-85
lines changed

google/cloud/sql/connector/refresh_utils.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ async def _get_metadata(
7979
:raises TypeError: If any of the arguments are not the specified type.
8080
"""
8181

82-
if not isinstance(project, str):
83-
raise TypeError(f"project must be of type str, got {type(project)}")
84-
if not isinstance(region, str):
85-
raise TypeError(f"region must be of type str, got {type(region)}")
86-
if not isinstance(instance, str):
87-
raise TypeError(f"instance must be of type str, got {type(instance)}")
88-
8982
if not credentials.valid:
9083
request = google.auth.transport.requests.Request()
9184
credentials.refresh(request)
@@ -167,10 +160,6 @@ async def _get_ephemeral(
167160

168161
logger.debug(f"['{instance}']: Requesting ephemeral certificate")
169162

170-
if not isinstance(project, str):
171-
raise TypeError(f"project must be of type str, got {type(project)}")
172-
if not isinstance(instance, str):
173-
raise TypeError(f"instance must be of type str, got {type(instance)}")
174163
if not isinstance(pub_key, str):
175164
raise TypeError(f"pub_key must be of type str, got {type(pub_key)}")
176165

tests/unit/mocks.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,6 @@ def generate_ephemeral(self, client_bytes: str) -> str:
278278
client_bytes.encode("UTF-8"), default_backend()
279279
) # type: ignore
280280
ephemeral_cert = client_key_signed_cert(self.cert, self.key, client_key)
281-
print(
282-
"Test generate time: ",
283-
datetime.datetime.utcnow() + datetime.timedelta(minutes=10),
284-
)
285281
return json.dumps(
286282
{
287283
"ephemeralCert": {

tests/unit/test_refresh_utils.py

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -93,38 +93,14 @@ async def test_get_ephemeral_TypeError(credentials: Credentials) -> None:
9393
when given incorrect input arg types.
9494
"""
9595
client_session = Mock(aiohttp.ClientSession)
96-
project = "my-project"
97-
instance = "my-instance"
98-
pub_key = "key"
99-
100-
# incorrect project type
101-
with pytest.raises(TypeError):
102-
await _get_ephemeral(
103-
client_session=client_session,
104-
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
105-
credentials=credentials,
106-
project=12345,
107-
instance=instance,
108-
pub_key=pub_key,
109-
)
110-
# incorrect instance type
111-
with pytest.raises(TypeError):
112-
await _get_ephemeral(
113-
client_session=client_session,
114-
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
115-
credentials=credentials,
116-
project=project,
117-
instance=12345,
118-
pub_key=pub_key,
119-
)
12096
# incorrect pub_key type
12197
with pytest.raises(TypeError):
12298
await _get_ephemeral(
12399
client_session=client_session,
124100
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
125101
credentials=credentials,
126-
project=project,
127-
instance=instance,
102+
project="my-project",
103+
instance="my-instance",
128104
pub_key=12345,
129105
)
130106

@@ -166,50 +142,6 @@ async def test_get_metadata(
166142
)
167143

168144

169-
@pytest.mark.asyncio
170-
@no_type_check
171-
async def test_get_metadata_TypeError(credentials: Credentials) -> None:
172-
"""
173-
Test to check whether _get_metadata throws proper TypeError
174-
when given incorrect input arg types.
175-
"""
176-
client_session = Mock(aiohttp.ClientSession)
177-
project = "my-project"
178-
region = "my-region"
179-
instance = "my-instance"
180-
181-
# incorrect project type
182-
with pytest.raises(TypeError):
183-
await _get_metadata(
184-
client_session=client_session,
185-
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
186-
credentials=credentials,
187-
project=12345,
188-
region=region,
189-
instance=instance,
190-
)
191-
# incorrect region type
192-
with pytest.raises(TypeError):
193-
await _get_metadata(
194-
client_session=client_session,
195-
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
196-
credentials=credentials,
197-
project=project,
198-
region=1,
199-
instance=instance,
200-
)
201-
# incorrect instance type
202-
with pytest.raises(TypeError):
203-
await _get_metadata(
204-
client_session=client_session,
205-
sqladmin_api_endpoint="https://sqladmin.googleapis.com",
206-
credentials=credentials,
207-
project=project,
208-
region=region,
209-
instance=12345,
210-
)
211-
212-
213145
@pytest.mark.asyncio
214146
@no_type_check
215147
async def test_get_metadata_region_mismatch(

0 commit comments

Comments
 (0)