Skip to content

Commit

Permalink
fixed timeout in Query, added file for live tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottekostelic committed Apr 10, 2024
1 parent c819927 commit 32c2282
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions bookops_worldcat/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Handles actual requests to OCLC services
"""
from __future__ import annotations
from typing import Optional, Union, Tuple, TYPE_CHECKING
from typing import Union, Tuple, TYPE_CHECKING
import sys

from requests.models import PreparedRequest
Expand All @@ -31,17 +31,20 @@ def __init__(
self,
session: MetadataSession,
prepared_request: PreparedRequest,
timeout: Optional[
Union[int, float, Tuple[int, int], Tuple[float, float]]
] = None,
timeout: Union[int, float, Tuple[int, int], Tuple[float, float], None] = (
5,
5,
),
) -> None:
"""Initializes Query object.
Args:
session: `metadata_api.MetadataSession` instance
prepared_request: `requests.models.PreparedRequest` instance
timeout: how long to wait for server to send data
before giving up
session: `metadata_api.MetadataSession` instance
prepared_request: `requests.models.PreparedRequest` instance
timeout: how long to wait for server to send data before
giving up; can accept different values for connect
and read timeouts. default value is 5 seconds for
read and 5 seconds for connect timeouts
Raises:
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def stub_holding_xml():
@pytest.fixture
def stub_marc21():
fh = os.path.join(
os.environ["USERPROFILE"], "github/bookops-worldcat/temp/test.mrc"
os.environ["USERPROFILE"], "github/bookops-worldcat/tests/test.mrc"
)
with open(fh, "rb") as stub:
stub_marc21 = stub.read()
Expand Down
1 change: 1 addition & 0 deletions tests/test.mrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
00266nam a2200097 a 4500008004100000010001700041040002200058100002700080245001600107500004500123120827s2012 nyua 000 0 eng d a 63011276  aOCWMSbengcOCWMS0 aOCLC Developer Network10aTest Record aFOR OCLC DEVELOPER NETWORK DOCUMENTATION

0 comments on commit 32c2282

Please sign in to comment.