Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

fix(odk): use payload filter with meta.instanceID #415

Merged
merged 3 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions aether-kernel/aether/kernel/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ class Meta:


class SubmissionFilter(filters.FilterSet):
instanceID = filters.CharFilter(
field_name='payload__meta__instanceID',
)
project = filters.CharFilter(
method='project_filter',
)
Expand Down
20 changes: 0 additions & 20 deletions aether-kernel/aether/kernel/api/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import json
import random
import uuid

from autofixture import generators
from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -252,25 +251,6 @@ def test_entity_filter__by_family(self):
result_by_id = set([r['id'] for r in response['results']])
self.assertEqual(expected, result_by_id, 'by family')

def test_submission_filter__by_instanceID(self):
def gen_submission_payload():
return {'meta': {'instanceID': str(uuid.uuid4())}}

url = reverse(viewname='submission-list')
generate_project(submission_field_values={
'payload': generators.CallableGenerator(gen_submission_payload),
})
for submission in models.Submission.objects.all():
instance_id = submission.payload['meta']['instanceID']
kwargs = {'instanceID': instance_id}
response = json.loads(
self.client.get(url, kwargs, format='json').content
)
self.assertEqual(response['count'], 1)
result = response['results'][0]
self.assertEqual(result['id'], str(submission.pk), 'by instanceID')
self.assertEqual(result['payload']['meta']['instanceID'], instance_id)

def test_submission_filter__by_project(self):
url = reverse(viewname='submission-list')
# Generate projects.
Expand Down
2 changes: 1 addition & 1 deletion aether-kernel/conf/extras/coverage.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ omit = *migrations*, *tests*
[report]
omit = *migrations*, *tests*, *settings.py
show_missing = true
fail_under = 80
fail_under = 95
2 changes: 1 addition & 1 deletion aether-odk-module/aether/odk/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def xform_submission(request):
previous_submissions_response = requests.get(
submissions_url,
headers=auth_header,
params={'instanceID': instance_id},
params={'payload__meta__instanceID': instance_id},
)
previous_submissions = json.loads(previous_submissions_response.content.decode('utf-8'))
previous_submissions_count = previous_submissions['count']
Expand Down