Skip to content

Commit

Permalink
added automatic retries to holdings tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottekostelic committed Nov 14, 2024
1 parent 4501873 commit 931f3d0
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions tests/webtests/test_metadata_api_live.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


@pytest.mark.webtest
@pytest.mark.usefixtures("live_keys")
class TestLiveMetadataSession:
"""Runs tests against live Metadata API"""

Expand Down Expand Up @@ -275,7 +274,13 @@ def test_holdings_get_current(self, live_token):

@pytest.mark.holdings
def test_holdings_set_unset(self, live_token):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
get_resp = session.holdings_get_current("850940548")
holdings = get_resp.json()["holdings"]

Expand All @@ -302,7 +307,13 @@ def test_holdings_set_unset(self, live_token):

@pytest.mark.holdings
def test_holdings_set_unset_cascadeDelete(self, live_token, stub_marc_xml):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
get_resp = session.holdings_get_current("850940548")
holdings = get_resp.json()["holdings"]

Expand All @@ -329,7 +340,13 @@ def test_holdings_set_unset_cascadeDelete(self, live_token, stub_marc_xml):

@pytest.mark.holdings
def test_holdings_set_unset_xml(self, live_token, stub_marc_xml):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
response = session.holdings_get_current("850940548")
holdings = response.json()["holdings"]

Expand Down Expand Up @@ -361,7 +378,13 @@ def test_holdings_set_unset_xml(self, live_token, stub_marc_xml):

@pytest.mark.holdings
def test_holdings_set_unset_xml_cascadeDelete(self, live_token, stub_marc_xml):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
response = session.holdings_get_current("850940548")
holdings = response.json()["holdings"]

Expand Down Expand Up @@ -600,7 +623,6 @@ def test_error_max_retries(self, stub_marc21):


@pytest.mark.webtest
@pytest.mark.usefixtures("live_keys")
class TestAPISpec:
"""Compares API spec with MetadataSession methods"""

Expand Down Expand Up @@ -796,7 +818,13 @@ def test_params_holdings_get_current(
def test_params_holdings_set_unset(
self, live_token, endpoint_params, method_params
):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
get_response = session.holdings_get_current("850940548")
holdings = get_response.json()["holdings"]
current_holding_endpoint_args = endpoint_params(
Expand Down Expand Up @@ -829,7 +857,13 @@ def test_params_holdings_set_unset(
def test_params_holdings_set_unset_with_bib(
self, live_token, endpoint_params, method_params, stub_marc_xml
):
with MetadataSession(authorization=live_token) as session:
with MetadataSession(
authorization=live_token,
totalRetries=3,
backoffFactor=0.5,
statusForcelist=[408, 500, 502, 503, 504],
allowedMethods=["GET", "POST"],
) as session:
get_response = session.holdings_get_current("850940548")
holdings = get_response.json()["holdings"]
current_holding_endpoint_args = endpoint_params(
Expand Down

0 comments on commit 931f3d0

Please sign in to comment.