Skip to content

Commit

Permalink
Fix the bad type annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
ntai-arxiv committed May 21, 2024
1 parent fa57db1 commit 99a6957
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions gcp/service_auth/tests/test_get_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import subprocess
import time
from typing import Generator
from typing import Generator, Tuple

import pytest
import logging
Expand All @@ -21,26 +21,33 @@

@pytest.fixture(scope="module")
#@pytest.mark.with_op
def gcp_browse_cred() -> (Generator[str, str, str], str):
def gcp_browse_cred() -> Generator[Tuple[str, str], None, None]:
"""The fixture sets up
1. the path to the credentials file
2. the URL to the service.
"""
logging.basicConfig(level=logging.DEBUG)
cred_file = os.path.join(Path(__file__).parent, "browse-local.json")
cred_file = cred_file
# the magic numbers are assigned by the 1password.
# You'd find the value by running `op item list`, etc.
if not os.path.exists(cred_file):
subprocess.run(["op", "document", "get", "4feibaz4tzn6iwk5c7ggvb7xwi", "-o", cred_file])
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = cred_file
op = subprocess.run(["op", "item", "get", "4feibaz4tzn6iwk5c7ggvb7xwi", "--format", "json"], stdout=subprocess.PIPE)
test_meta = json.loads(op.stdout)
test_url = ""
for field in test_meta['fields']:
# the magic number is assigned by 1p. This is a URL to test against
if field["id"] == "heltf7phky3h6rnlvd7zi3542u":
test_url = field["value"]
break
yield (cred_file, test_url)
yield cred_file, test_url
os.remove(cred_file)
return ""
return

@pytest.mark.with_op
def test_get_token(gcp_browse_cred: (str, str)) -> None:
def test_get_token(gcp_browse_cred: Tuple[str, str]) -> None:
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = gcp_browse_cred[0]
logger = logging.getLogger("test")
idt = GcpIdentityToken(gcp_browse_cred[0][1], logger=logger,
Expand Down

0 comments on commit 99a6957

Please sign in to comment.