Browse Source

HUE-7253 [editor] FIX file download content-disposition test

jdesjean 7 years ago
parent
commit
7b3bc4008d

File diff suppressed because it is too large
+ 3 - 3
apps/search/src/search/tests.py


+ 2 - 2
desktop/core/src/desktop/tests_doc2.py

@@ -1050,11 +1050,11 @@ class TestDocument2ImportExport(object):
 
     # Test that exporting to a file includes the date and number of documents in the filename
     response = self.client.get('/desktop/api2/doc/export/', {'documents': json.dumps([workflow.id, workflow2.id])})
-    assert_equal(response['Content-Disposition'], 'attachment; filename=hue-documents-%s-(4).json' % datetime.today().strftime('%Y-%m-%d'))
+    assert_equal(response['Content-Disposition'], 'attachment; filename="hue-documents-%s-(4).json"' % datetime.today().strftime('%Y-%m-%d'))
 
     # Test that exporting single file gets the name of the document in the filename
     response = self.client.get('/desktop/api2/doc/export/', {'documents': json.dumps([workflow.id])})
-    assert_equal(response['Content-Disposition'], 'attachment; filename=' + workflow.name + '.json')
+    assert_equal(response['Content-Disposition'], 'attachment; filename="' + workflow.name + '.json"')
 
 
   def test_export_directories_with_children(self):

+ 1 - 1
desktop/libs/dashboard/src/dashboard/api.py

@@ -296,7 +296,7 @@ def download(request):
     if file_format == 'json':
       docs = response['response']['docs']
       resp = JsonResponse(docs, safe=False)
-      resp['Content-Disposition'] = 'attachment; filename=%s.%s' % ('query_result', file_format)
+      resp['Content-Disposition'] = 'attachment; filename="%s.%s"' % ('query_result', file_format)
       return resp
     else:
       return export_download(response, file_format, collection)

+ 3 - 3
desktop/libs/dashboard/src/dashboard/tests.py

@@ -480,7 +480,7 @@ class TestWithMockedSolr(TestSearchBase):
 
     json_response_content = json.loads(json_response.content)
     assert_equal('application/json', json_response['Content-Type'])
-    assert_equal('attachment; filename=query_result.json', json_response['Content-Disposition'])
+    assert_equal('attachment; filename="query_result.json"', json_response['Content-Disposition'])
     assert_equal(4, len(json_response_content), len(json_response_content))
     assert_equal('Investigations for neonatal seizures.', json_response_content[0]['article_title'])
 
@@ -491,7 +491,7 @@ class TestWithMockedSolr(TestSearchBase):
     })
     csv_response_content = ''.join(csv_response.streaming_content)
     assert_equal('application/csv', csv_response['Content-Type'])
-    assert_equal('attachment; filename=query_result.csv', csv_response['Content-Disposition'])
+    assert_equal('attachment; filename="query_result.csv"', csv_response['Content-Disposition'])
     assert_equal(4 + 1 + 1, len(csv_response_content.split('\n')), csv_response_content.split('\n'))
     assert_true('<script>alert(1234)</script>,_version_,author,category,comments,content,content_type,description,features,inStock,includes,keywords,last_modified,links,manu,manu_exact,name,payloads,popularity,price,resourcename,sku,store,subject,text,text_rev,title,url,weight,id' in csv_response_content, csv_response_content)
     # Fields does not exactly match the response but this is because the collection schema does not match the query response.
@@ -505,7 +505,7 @@ class TestWithMockedSolr(TestSearchBase):
     xls_response_content = ''.join(xls_response.content)
     assert_not_equal(0, len(xls_response_content))
     assert_equal('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', xls_response['Content-Type'])
-    assert_equal('attachment; filename=query_result.xlsx', xls_response['Content-Disposition'])
+    assert_equal('attachment; filename="query_result.xlsx"', xls_response['Content-Disposition'])
 
   def test_index_xss(self):
     doc = Document2.objects.create(name='test_dashboard', type='search-dashboard', owner=self.user,

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/tests/tests_hiveserver2.py

@@ -646,7 +646,7 @@ class TestHiveserver2ApiWithHadoop(BeeswaxSampleProvider):
                                 {'notebook': notebook.get_json(), 'snippet': json.dumps(snippet), 'format': 'csv'})
 
     assert_equal(200, response.status_code)
-    assert_equal(('Content-Disposition', 'attachment; filename=Test Query.csv'), response._headers['content-disposition'])
+    assert_equal(('Content-Disposition', 'attachment; filename="Test Query.csv"'), response._headers['content-disposition'])
 
 
   def test_get_sample(self):

Some files were not shown because too many files changed in this diff