diff --git a/onadata/apps/api/tests/viewsets/test_briefcase_viewset.py b/onadata/apps/api/tests/viewsets/test_briefcase_viewset.py index cc8ce908a7..bfb984a611 100644 --- a/onadata/apps/api/tests/viewsets/test_briefcase_viewset.py +++ b/onadata/apps/api/tests/viewsets/test_briefcase_viewset.py @@ -301,7 +301,8 @@ def test_view_downloadSubmission(self): text = f.read() for var in ((u'{{submissionDate}}', instance.date_created.isoformat()), - (u'{{form_id}}', str(self.xform.id))): + (u'{{form_id}}', str(self.xform.id)), + (u'{{media_id}}', str(self.attachment.id))): text = text.replace(*var) self.assertContains(response, instanceId, status_code=200) self.assertMultiLineEqual(response.content.decode('utf-8'), text) @@ -466,7 +467,8 @@ def test_view_downloadSubmission_no_xmlns(self, mock_get_object): text = f.read() for var in ((u'{{submissionDate}}', instance.date_created.isoformat()), - (u'{{form_id}}', str(self.xform.id))): + (u'{{form_id}}', str(self.xform.id)), + (u'{{media_id}}', str(self.attachment.id))): text = text.replace(*var) self.assertNotIn( 'transportation id="transportation_2011_07_25"' @@ -521,7 +523,8 @@ def test_view_downloadSubmission_multiple_nodes(self, mock_get_object): text = f.read() for var in ((u'{{submissionDate}}', instance.date_created.isoformat()), - (u'{{form_id}}', str(self.xform.id))): + (u'{{form_id}}', str(self.xform.id)), + (u'{{media_id}}', str(self.attachment.id))): text = text.replace(*var) self.assertContains(response, instanceId, status_code=200) diff --git a/onadata/apps/logger/templates/downloadSubmission.xml b/onadata/apps/logger/templates/downloadSubmission.xml index 4dbee8df4f..0727f0ab28 100644 --- a/onadata/apps/logger/templates/downloadSubmission.xml +++ b/onadata/apps/logger/templates/downloadSubmission.xml @@ -6,6 +6,6 @@ {% for media in media_files %} {{ media.name|safe }} md5:{{ media.file_hash }} - {{ host }}{% url "attachment_url" 'original' %}?media_file={{ media.media_file.name|safe }}&attachment_id={{ media.pk }} + {{ host }}{% url "attachment_url" 'original' %}?media_file={{ media.media_file.name|safe }}&attachment_id={{ media.pk }} {% endfor %} diff --git a/onadata/apps/logger/tests/test_briefcase_api.py b/onadata/apps/logger/tests/test_briefcase_api.py index 93bb54e82f..1f9875665d 100644 --- a/onadata/apps/logger/tests/test_briefcase_api.py +++ b/onadata/apps/logger/tests/test_briefcase_api.py @@ -223,7 +223,7 @@ def test_view_downloadSubmission(self): for var in ( ("{{submissionDate}}", instance.date_created.isoformat()), ("{{form_id}}", str(self.xform.id)), - ("{{attachment_id}}", str(self.attachment.id)), + ("{{media_id}}", str(self.attachment.id)), ): text = text.replace(*var) self.assertContains(response, instanceId, status_code=200) diff --git a/onadata/apps/main/tests/fixtures/transportation/view/downloadSubmission.xml b/onadata/apps/main/tests/fixtures/transportation/view/downloadSubmission.xml index 0deba37c3d..d574e55c1d 100644 --- a/onadata/apps/main/tests/fixtures/transportation/view/downloadSubmission.xml +++ b/onadata/apps/main/tests/fixtures/transportation/view/downloadSubmission.xml @@ -6,6 +6,6 @@ 1335783522563.jpg md5:2ca0d22073a9b6b4ebe51368b08da60c - http://testserver/attachment/original?media_file=bob/attachments/{{form_id}}_transportation_2011_07_25/1335783522563.jpg&attachment_id={{attachment_id}} + http://testserver/attachment/original?media_file=bob/attachments/{{form_id}}_transportation_2011_07_25/1335783522563.jpg&attachment_id={{media_id}} diff --git a/onadata/apps/viewer/tests/test_attachment_url.py b/onadata/apps/viewer/tests/test_attachment_url.py index 8a96beed8e..166a72568d 100644 --- a/onadata/apps/viewer/tests/test_attachment_url.py +++ b/onadata/apps/viewer/tests/test_attachment_url.py @@ -44,13 +44,16 @@ def test_attachment_has_mimetype(self): self.assertEqual(attachment.mimetype, 'image/jpeg') def test_attachment_url_w_media_id(self): + """Test attachment url with attachment id""" self.assertEqual( Attachment.objects.count(), self.attachment_count + 1) response = self.client.get( self.url, {"attachment_id": self.attachment.id}) self.assertEqual(response.status_code, 302) # redirects to amazon + # pylint: disable=invalid-name def test_attachment_url_w_media_id_no_redirect(self): + """Test attachment url with attachment id no redirect""" self.assertEqual( Attachment.objects.count(), self.attachment_count + 1) response = self.client.get(