Skip to content

Commit

Permalink
Fixed and tests issue #49 : Autocomplete on multiple field retrieves … (
Browse files Browse the repository at this point in the history
#51)

* Fixed and tests issue #49 : Autocomplete on multiple field retrieves values using  now

* Update some requirements
  • Loading branch information
PonteIneptique authored and Jean-Baptiste-Camps committed May 4, 2018
1 parent 238564b commit b12ee25
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
8 changes: 6 additions & 2 deletions app/models/linguistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,13 @@ def get_like(corpus_id, form, group_by, type_like="lemma", allowed_list=False):
query = query.filter(
db.and_(
cls.corpus == corpus_id,
# This or is applied on the different field : you can either have readable or label with a match
db.or_(*[
query_field.ilike("%{}%".format(fsplitted))
for fsplitted in form
# But all the values that are given should match !
db.and_(*[
query_field.ilike("%{}%".format(fsplitted))
for fsplitted in form
])
for query_field in query_fields
])
)
Expand Down
2 changes: 1 addition & 1 deletion chromedriver.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
wget -N https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip -P ~/
wget -N https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip
sudo mv -f ~/chromedriver /usr/local/share/
Expand Down
4 changes: 3 additions & 1 deletion contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ To run tests, you will need [chrome-webdriver](https://chromedriver.storage.goog

### Install webdriver on Linux

**Note:** this script is also available as `chromedriver.sh` in the root directory of this repository

```shell
wget -N https://chromedriver.storage.googleapis.com/2.32/chromedriver_linux64.zip -P ~/
wget -N https://chromedriver.storage.googleapis.com/2.36/chromedriver_linux64.zip -P ~/
unzip ~/chromedriver_linux64.zip -d ~/
rm ~/chromedriver_linux64.zip
sudo mv -f ~/chromedriver /usr/local/share/
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ selenium>=3.6.0
nose2==0.6.5
cov-core==1.15.0
click==6.7
mock==2.0.0
mock==2.0.0
nose
22 changes: 22 additions & 0 deletions tests/test_requesting/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ def test_lemma_autocomplete(self):
non_accentuated = json.loads(self.client.get("/corpus/1/api/lemma?form=oir").data.decode())
self.assertEqual(non_accentuated, ["öir"])

def test_morph_autocomplete(self):
""" Test that morph autocomplete works fine with accentuated or non accentuated chars """
self.addCorpus(corpus="floovant", with_token=True, with_allowed_morph=True)
accentuated = json.loads(self.client.get("/corpus/2/api/morph?form=2 plur").data.decode())
self.assertEqual(accentuated, [
{'label': 'impératif 2e personne pluriel',
'value': 'MODE=imp|PERS.=2|NOMB.=p'},
{'label': '2e personne pluriel masculin régime',
'value': 'PERS.=2|NOMB.=p|GENRE=m|CAS=r'},
])
non_accentuated = json.loads(self.client.get("/corpus/2/api/morph?form=%3Dr %3Dp").data.decode())
self.assertEqual(
non_accentuated,
[{'label': 'pluriel masculin régime', 'value': 'NOMB.=p|GENRE=m|CAS=r'},
{'label': 'singulier féminin régime positif',
'value': 'NOMB.=s|GENRE=f|CAS=r|DEGRE=p'},
{'label': '2e personne pluriel masculin régime',
'value': 'PERS.=2|NOMB.=p|GENRE=m|CAS=r'},
{'label': '3e personne pluriel masculin régime',
'value': 'PERS.=3|NOMB.=p|GENRE=m|CAS=r'}]
)

def test_edit_then_apply_similar(self):
""" Test that lemma autocomplete works fine with accentuated or non accentuated chars """
self.addCorpus(corpus="wauchier", with_token=True)
Expand Down

0 comments on commit b12ee25

Please sign in to comment.