From 37e4be24129b6980e3e9fced7345d4a596af3d58 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 14 Apr 2019 19:41:30 +0200 Subject: digikey: o More flexibility, making room for the multiple digikey stores. o Removing URLs from core code. new tools: split_parts_by_supplier. --- test/test_digikey.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_digikey.py b/test/test_digikey.py index 2e9b1f1..568360e 100644 --- a/test/test_digikey.py +++ b/test/test_digikey.py @@ -12,7 +12,8 @@ static_copies = basedir / "digikey" / "static-copies" # type: Path digikey = dk.Digikey() parser = dk.DigikeyParser(digikey) -client = dk.DigikeyClient(cache_dir=basedir / "digikey" / "static-copies", on_download=print) +client = dk.DigikeyClient("https://www.digikey.com/products/en", cache_dir=basedir / "digikey" / "static-copies", + on_download=print) force_refresh = False # Set to True to always fetch the updated html files @@ -83,3 +84,26 @@ def test_digikey_3(): p = next((p for p in res.products if p.part_number == "1655-1501-1-ND"), None) assert p.mpn == "RS1MTR" assert p.url == "/product-detail/en/smc-diode-solutions/RS1MTR/1655-1501-1-ND/6022946" + + +@pytest.mark.digikey +def test_store(): + store = dk.DigikeyStore.from_store_code("us") + assert store.products_url == "https://www.digikey.com/products/en" + assert store.url == "http://purl.org/ee/supplier/digikey?store=us" + assert store.store == "us" + + store = dk.DigikeyStore.from_url(store.url) + assert store.products_url == "https://www.digikey.com/products/en" + assert store.url == "http://purl.org/ee/supplier/digikey?store=us" + assert store.store == "us" + + store = dk.DigikeyStore.from_store_code("no") + assert store.products_url == "https://www.digikey.no/products/en" + assert store.url == "http://purl.org/ee/supplier/digikey?store=no" + assert store.store == "no" + + store = dk.DigikeyStore.from_url(store.url) + assert store.products_url == "https://www.digikey.no/products/en" + assert store.url == "http://purl.org/ee/supplier/digikey?store=no" + assert store.store == "no" -- cgit v1.2.3