nanterre: lister seulement les nouveaux doublons par défaut (#20344)

This commit is contained in:
Thomas NOËL 2017-11-29 11:09:41 +01:00
parent 32df9a9dfd
commit c53ff1d74f
2 changed files with 31 additions and 1 deletions

View File

@ -28,7 +28,7 @@ def test_list_doublons(nanterre_classic_family, app):
assert response.json['data'][0]['score'] == 100
new = []
for i in range(100):
for i in range(90):
new.append(copy.deepcopy(e['jean']))
new[-1].id = None
new[-1].save()
@ -52,6 +52,13 @@ def test_list_doublons(nanterre_classic_family, app):
first_data = response.json['data'][0]
second_data = response.json['data'][1]
url = reverse('rsu-api-doublons') + '?limit=100'
response = app.get(url)
assert response.json['err'] == 0
assert 'more' not in response.json
assert 'cookie' not in response.json
assert len(response.json['data']) == 91
url = reverse('rsu-api-doublons') + '?score_min=90&limit=100'
response = app.get(url)
assert response.json['err'] == 0
@ -79,6 +86,13 @@ def test_list_doublons(nanterre_classic_family, app):
assert response.json['err'] == 0
assert Duplicate.objects.get(id=second_data['id']).state == Duplicate.STATE_FALSE_POSITIVE
url = reverse('rsu-api-doublons') + '?false_positive=1'
response = app.get(url)
assert response.json['err'] == 0
assert 'more' not in response.json
assert 'cookie' not in response.json
assert len(response.json['data']) == 1
response = app.post(false_positive_url, status=500)
assert response.json['err'] == 1
@ -93,3 +107,17 @@ def test_list_doublons(nanterre_classic_family, app):
d.refresh_from_db()
assert d.state == Duplicate.STATE_DEDUP
assert d.content['dedup_choice'] == 1
url = reverse('rsu-api-doublons') + '?dedup=1'
response = app.get(url)
assert response.json['err'] == 0
assert 'more' not in response.json
assert 'cookie' not in response.json
assert len(response.json['data']) == 1
url = reverse('rsu-api-doublons') + '?limit=100'
response = app.get(url)
assert response.json['err'] == 0
assert 'more' not in response.json
assert 'cookie' not in response.json
assert len(response.json['data']) == 89

View File

@ -1890,6 +1890,8 @@ class DoublonsView(DoublonMixin, APIView):
qs = qs.filter(state=models.Duplicate.STATE_FALSE_POSITIVE)
elif dedup:
qs = qs.filter(state=models.Duplicate.STATE_DEDUP)
else:
qs = qs.filter(state=models.Duplicate.STATE_NEW)
if 'score_min' in request.GET:
try: