From 2e2956823c9cd02c766b296cbcbea9130bd07b36 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 28 May 2019 09:46:41 +0200 Subject: digikey: Better search when getting multiple results back. Instead of doing a new search with the selected digikey part number, do a direct lookup with the product's URL instead. This ensures that we always get a match and don't get confused when multiple part numbers are returned. --- test/test_digikey.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/test_digikey.py b/test/test_digikey.py index 528ed8e..f1b010b 100644 --- a/test/test_digikey.py +++ b/test/test_digikey.py @@ -21,7 +21,7 @@ force_refresh = False # Set to True to always fetch the updated html files def test_digikey_1(tmpdir): content = client.search("TCR2LF18LM(CTTR-ND") - res = parser.parse_string(content) + res = parser.parse_string(client.baseurl, content) assert res.response_type == dk.SearchResponseTypes.SINGLE p = res.products[0] assert p.part_number == "TCR2LF18LM(CTTR-ND" @@ -50,7 +50,7 @@ def test_digikey_1(tmpdir): def test_digikey_2(): content = client.product_search("TCR2LF", page_size=500) - res = parser.parse_string(content) + res = parser.parse_string(client.baseurl, content) assert res.response_type == dk.SearchResponseTypes.MANY [print("dpn={}, mpn={}".format(p.part_number, p.mpn)) for p in res.products] assert len(res.products) > 10 @@ -64,7 +64,7 @@ def test_digikey_2(): content = client.product_search(dpn) - res = parser.parse_string(content) + res = parser.parse_string(client.baseurl, content) assert res.response_type == dk.SearchResponseTypes.SINGLE p = res.products[0] @@ -76,7 +76,7 @@ def test_digikey_2(): def test_digikey_3(): content = client.product_search("RS1MTR") - res = parser.parse_string(content) + res = parser.parse_string(client.baseurl, content) assert res.response_type == dk.SearchResponseTypes.MANY [print("dpn={}, mpn={}".format(p.part_number, p.mpn)) for p in res.products] assert len(res.products) > 0 -- cgit v1.2.3