Skip to content

Commit

Permalink
Fix #157
Browse files Browse the repository at this point in the history
  • Loading branch information
eeintech committed Aug 4, 2023
1 parent a78b14f commit d22dcd8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
15 changes: 8 additions & 7 deletions kintree/common/part_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,16 @@ def clean_parameter_value(category: str, name: str, value: str) -> str:
# Clean-up ranges
separator = '~'
if separator in value:
split_space = value.split()
first_value = split_space[0]
second_value = split_space[2]
space_split = value.split()
first_value = space_split[0]
if len(space_split) > 2:
second_value = space_split[2]

# Substract digits, negative sign, points from first value to get unit
unit = first_value.replace(re.findall('[-.0-9]*', first_value)[0], '')
# Substract digits, negative sign, points from first value to get unit
unit = first_value.replace(re.findall('[-.0-9]*', first_value)[0], '')

if unit:
value = first_value.replace(unit, '') + separator + second_value
if unit:
value = first_value.replace(unit, '') + separator + second_value

# Remove parenthesis section
if '(' in value:
Expand Down
3 changes: 2 additions & 1 deletion kintree/config/inventree/inventree_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PASSWORD: !!binary |
''
PROXIES: null
SERVER_ADDRESS: ''
USERNAME: ''
USERNAME: ''
DATASHEET_UPLOAD: false
3 changes: 2 additions & 1 deletion kintree/config/inventree/inventree_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PASSWORD: !!binary |
''
PROXIES: null
SERVER_ADDRESS: ''
USERNAME: ''
USERNAME: ''
DATASHEET_UPLOAD: false
17 changes: 11 additions & 6 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ def check_result(status: str, new_part: bool) -> bool:
else:
cprint('[ PASS ]')

# Test Element14 API
# Test Element14 API (with retry, to avoid the few false positives)
if 'Element14' in settings.SUPPORTED_SUPPLIERS_API:
pretty_test_print('[MAIN]\tElement14 API Test')
if not element14_api.test_api() or not element14_api.test_api(store_url='www.newark.com'):
cprint('[ FAIL ]')
for i in range(2):
pretty_test_print('[MAIN]\tElement14 API Test')
if not element14_api.test_api() or not element14_api.test_api(store_url='www.newark.com'):
cprint('[ FAIL ]')
else:
cprint('[ PASS ]')
break
sys.exit(-1)
else:
cprint('[ PASS ]')

# Test LCSC API
if 'LCSC' in settings.SUPPORTED_SUPPLIERS_API:
Expand Down Expand Up @@ -258,6 +260,9 @@ def check_result(status: str, new_part: bool) -> bool:
cprint(f'[DBUG]\tnew_part = {new_part}')
cprint(f'[DBUG]\tpart_pk = {part_pk}')

# Disable datasheet download/upload after first part (to speed up testing)
settings.DATASHEET_UPLOAD = False

if ENABLE_TEST_METHODS:
methods = [
'Fuzzy category matching',
Expand Down
2 changes: 2 additions & 0 deletions tests/files/inventree_dev.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
DATASHEET_UPLOAD: true
ENABLE: true
ENABLE_PROXY: false
PASSWORD: !!binary |
WVdSdGFXND0=
SERVER_ADDRESS: http://127.0.0.1:8000/
USERNAME: admin
PROXIES: null

0 comments on commit d22dcd8

Please sign in to comment.