Skip to content

Commit

Permalink
add test for video metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Feb 6, 2025
1 parent eb90d82 commit 74ed422
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/keepa/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,17 +630,17 @@ def query(
active.
raw : bool, default; False
When ``True``, return the raw request response. This is
only available in the non-async class.
When ``True``, return the raw request response. This is only
available in the non-async class.
videos : bool, optional
Token Cost: No extra token cost
Boolean value (0 = false, 1 = true). If specified and set to 1, the
videos metadata will be provided when available. Using this
parameter does not trigger an update to the videos data; it only
gives access to our existing data if available. If you need
up-to-date data, you have to use the offers parameter.
If ``True``, the videos metadata will be provided when
available. Using this parameter does not trigger an update to the
videos data; it only gives access to our existing data if
available. If you need up-to-date data, you have to use the offers
parameter.
Returns
-------
Expand Down Expand Up @@ -826,6 +826,14 @@ def query(
118 2023-10-27 08:14:00 A1U9HDFCZO1A84 Used - Like New False
119 2023-10-27 12:34:00 AYUGEV9WZ4X5O Used - Like New False
Query a video with the "videos" metadata.
>>> response = api.query("B00UFMKSDW", history=False, videos=True)
>>> product = response[0]
>>> "videos" in product
True
"""
# Format items into numpy array
try:
Expand Down Expand Up @@ -1767,6 +1775,7 @@ async def query(
days: Optional[int] = None,
only_live_offers: Optional[bool] = None,
raw: bool = False,
videos: bool = False,
):
"""Documented in Keepa.query."""
if raw:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# just need an active product with a buybox
PRODUCT_ASIN = "0593440412"
HARD_DRIVE_PRODUCT_ASIN = "B0088PUEPK"
VIDEO_ASIN = "B0060CU5DE"

# ASINs of a bunch of chairs generated with
# categories = API.search_for_categories('chairs')
Expand Down Expand Up @@ -422,3 +423,14 @@ def test_seller_query_long_list(api):
seller_id = ["A2L77EE7U53NWQ"] * 200
with pytest.raises(RuntimeError):
api.seller_query(seller_id)


def test_video_query(api) -> None:
"""Test if the videos query parameter works."""
response = api.query("B00UFMKSDW", history=False, videos=False)
product = response[0]
assert "videos" not in product

response = api.query("B00UFMKSDW", history=False, videos=True)
product = response[0]
assert "videos" in product

0 comments on commit 74ed422

Please sign in to comment.