Skip to content

Commit

Permalink
test: cache graph api key and restore it to env after
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Dec 4, 2024
1 parent 16b80aa commit c9ade57
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/test_subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,23 @@ def test_find_all_subgraph_urls(subgraph_all_chains, have_thegraph_key, subgraph
pytest.skip(
f"No {subgraph_type} subgraph exists on {subgraph_all_chains.chain}"
)
os.environ["GRAPH_API_KEY"] = (
os.getenv("GRAPH_API_KEY") if have_thegraph_key else ""
)

if not have_thegraph_key:
# temporarily remove the key
cached_graph_api_key = os.environ["GRAPH_API_KEY"]
os.environ["GRAPH_API_KEY"] = ""
subgraph_all_chains.set_silence_warnings(True)

url = subgraph_all_chains.get_subgraph_url(subgraph_type)

assert url is not None
assert url is not ""

if not have_thegraph_key:
# restore the key
os.environ["GRAPH_API_KEY"] = cached_graph_api_key
subgraph_all_chains.set_silence_warnings(False)


def test_warning_configuration(monkeypatch):
monkeypatch.setenv("GRAPH_API_KEY", "")
Expand Down

0 comments on commit c9ade57

Please sign in to comment.