From a60aa2cf1b086c0ace94d9f92bdc169f50dc7a3a Mon Sep 17 00:00:00 2001 From: eeintech Date: Sun, 29 Dec 2024 13:57:37 -0500 Subject: [PATCH] Test DK API #2 --- kintree/search/digikey_api.py | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/kintree/search/digikey_api.py b/kintree/search/digikey_api.py index f25b399..fb5c9b1 100644 --- a/kintree/search/digikey_api.py +++ b/kintree/search/digikey_api.py @@ -60,7 +60,6 @@ def setup_environment(force=False) -> bool: os.environ['DIGIKEY_LOCAL_SITE'] = digikey_api_settings.get('DIGIKEY_LOCAL_SITE', 'US') os.environ['DIGIKEY_LOCAL_LANGUAGE'] = digikey_api_settings.get('DIGIKEY_LOCAL_LANGUAGE', 'en') os.environ['DIGIKEY_LOCAL_CURRENCY'] = digikey_api_settings.get('DIGIKEY_LOCAL_CURRENCY', 'USD') - print(os.environ) return check_environment() @@ -112,27 +111,6 @@ def digikey_search_timeout(): x_digikey_locale_currency=os.environ['DIGIKEY_LOCAL_CURRENCY'], ).to_dict() - # THIS METHOD WILL NOT WORK WITH DIGI-KEY PART NUMBERS... - # @timeout(dec_timeout=20) - # def digikey_search_timeout(): - # from digikey.v3.productinformation.models.manufacturer_product_details_request import ManufacturerProductDetailsRequest - # # Set parametric filter for Cut Tape - # parametric_filters = { - # "ParameterId": 7, - # "ValueId": "2", - # } - # # Create search request body - # # TODO: record_count and filters parameter do not seem to work as intended - # search_request = ManufacturerProductDetailsRequest(manufacturer_product=part_number, record_count=1, filters=parametric_filters) - # # Run search - # manufacturer_product_details = digikey.manufacturer_product_details(body=search_request).to_dict() - # from ..common.tools import cprint - # print(f'length of response = {len(manufacturer_product_details.get("product_details", None))}') - # if type(manufacturer_product_details.get('product_details', None)) == list: - # # Return the first item only - # return manufacturer_product_details.get('product_details', None)[0] - # else: - # return {} # Method to process price breaks def process_price_break(product_variation): part_info['digi_key_part_number'] = product_variation.get(digi_number_key) @@ -225,8 +203,6 @@ def process_price_break(product_variation): def test_api(check_content=False) -> bool: ''' Test method for API token ''' - setup_environment() - test_success = True expected = { 'product_description': 'RES 10K OHM 5% 1/16W 0402', @@ -239,6 +215,7 @@ def test_api(check_content=False) -> bool: } test_part = fetch_part_info('RMCF0402JT10K0') + print(f'{test_part=}') # Check for response if not test_part: