Skip to content

Commit

Permalink
test: skip gene expression query tests if allen api is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmetNSimsek committed Oct 17, 2024
1 parent 6e4b4c9 commit 8bc16bb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion e2e/features/molecular/test_genes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import pytest
import siibra
from typing import Union, List
from json import JSONDecodeError
from functools import wraps
import siibra


def skip_if_allen_api_unavailable(test_func):
@wraps(test_func)
def wrapper(*args, **kwargs):
try:
return test_func(*args, **kwargs)
except JSONDecodeError:
pytest.skip(
f"Skipping test {test_func.__name__} due to JSONDecodeError since Allen API sent a malformed JSON"
)
except RuntimeError as e:
if str(e) == "Allen institute site unavailable - please try again later.":
pytest.skip("Skipping since Allen Institute API is unavailable.")
else:
raise e

return wrapper


test_params = [
("julich 2.9", "hoc1 left", "MAOA"),
Expand All @@ -13,6 +34,7 @@


@pytest.mark.parametrize("parc_spec, region_spec, gene", test_params)
@skip_if_allen_api_unavailable
def test_genes(parc_spec: str, region_spec: str, gene: Union[str, List[str]]):
parc = siibra.parcellations[parc_spec]
region = parc.get_region(region_spec)
Expand All @@ -23,6 +45,7 @@ def test_genes(parc_spec: str, region_spec: str, gene: Union[str, List[str]]):
), "expecting all features to be of type GeneExpression"


@skip_if_allen_api_unavailable
def test_gene_exp_w_parent_structures():
kwargs = {"gene": "MAOA"}
features_grandparent_struct = siibra.features.get(
Expand Down

0 comments on commit 8bc16bb

Please sign in to comment.