Commit c26f8239 authored by David Foucher's avatar David Foucher

Refactor (routine): simplify idcc search routine

parent 48f5db7b
......@@ -136,6 +136,6 @@ def test_build_catalog_url(monkeypatch):
@pytest.mark.parametrize('term', ['coiff', '2596'])
def test_search_idcc_code_by_word(term):
data = [{'2596': {'Convention collective': 'Coiffure', 'OPCA': 'AGEFOS PME',
'OPACIF': 'Fongecif'}}]
data = {'2596': {'Convention collective': 'Coiffure', 'OPCA': 'AGEFOS PME',
'OPACIF': 'Fongecif'}}
assert routine.search_idcc(term) == data
......@@ -296,12 +296,12 @@ def check_financement(context, financement):
def search_idcc(term):
data = []
data = {}
for k in IDCC:
if k.startswith(term):
data.append({k: IDCC[k]})
data[k] = IDCC[k]
else:
for v in IDCC[k]:
if IDCC[k][v].lower().startswith(term.lower()):
data.append({k: IDCC[k]})
data[k] = IDCC[k]
return data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment