From 090a2703703877bd150aae637031c5d7dcba2df4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 10 Sep 2017 12:32:49 +0200 Subject: setup.py: Adding install_requires. digikey: Updating tests. Making sure the directory exist before writing facts. Stop recursing into new searches when a search returns multiple hits. Let the frontends do that. --- test/test_digikey.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/test_digikey.py b/test/test_digikey.py index 6073e25..7509e2b 100644 --- a/test/test_digikey.py +++ b/test/test_digikey.py @@ -6,23 +6,23 @@ import sys basedir = os.path.dirname(os.path.abspath(__file__)) digikey = dk.Digikey() -client = dk.DigikeyClient(digikey) +client = dk.DigikeyClient(digikey, on_download=print) def test_digikey_1(): - p = client.search("TCR2LF18LM(CTTR-ND") - assert isinstance(p, dk.DigikeyProduct) + res = client.search("TCR2LF18LM(CTTR-ND") + assert res.response_type == dk.SearchResponseTypes.SINGLE + p = res.products[0] assert p.part_number == "TCR2LF18LM(CTTR-ND" + assert p.mpn == "TCR2LF18,LM(CT" assert len(p.attributes) > 5 x = p.to_yaml() - print(type(x)) - print("{}".format(x)) + print(str(x)) yaml.dump(x, sys.stdout) def test_digikey_2(): - response = client.search("TCR2LF") - [print(p.part_id) for p in response.products] - assert len(response.products) == 28 - # p = products[0] - # assert p.part_number == "TCR2LF18LM(CTTR-ND" + res = client.search("TCR2LF", page_size=500) + assert res.response_type == dk.SearchResponseTypes.MANY + [print(p.part_number) for p in res.products] + assert len(res.products) == 28 -- cgit v1.2.3