Skip to content

Commit d1668c4

Browse files
committed
make BEA tests optional
1 parent b8b9133 commit d1668c4

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/test_bea/test_api.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1+
from typing import Callable
2+
3+
import pytest
4+
from requests import HTTPError
5+
16
import finagg
27

38

9+
def skip_if_503(f: Callable) -> None:
10+
"""The BEA API is notorious for being unreliable. We don't really
11+
support maintaining the BEA API's Python client implementation anymore,
12+
so we just skip if they error out. We'll keep them just in case we
13+
feel like supporting it in the future.
14+
15+
"""
16+
try:
17+
f()
18+
except HTTPError as e:
19+
if e.response.status_code == 503:
20+
pytest.skip()
21+
22+
423
def test_fixed_assets_get_parameter_list() -> None:
5-
finagg.bea.api.fixed_assets.get_parameter_list()
24+
skip_if_503(finagg.bea.api.fixed_assets.get_parameter_list)
625

726

827
def test_gdp_by_industry_get_parameter_list() -> None:
9-
finagg.bea.api.gdp_by_industry.get_parameter_list()
28+
skip_if_503(finagg.bea.api.gdp_by_industry.get_parameter_list)
1029

1130

1231
def test_input_output_get_parameter_list() -> None:
13-
finagg.bea.api.input_output.get_parameter_list()
32+
skip_if_503(finagg.bea.api.input_output.get_parameter_list)
1433

1534

1635
def test_nipa_get_parameter_list() -> None:
17-
finagg.bea.api.nipa.get_parameter_list()
36+
skip_if_503(finagg.bea.api.nipa.get_parameter_list)

0 commit comments

Comments
 (0)