|
@@ -1,4 +1,5 @@
|
|
|
#!/usr/bin/env python
|
|
#!/usr/bin/env python
|
|
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
# Licensed to Cloudera, Inc. under one
|
|
# Licensed to Cloudera, Inc. under one
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
# distributed with this work for additional information
|
|
# distributed with this work for additional information
|
|
@@ -39,6 +40,25 @@ def test_export_csv():
|
|
|
assert_equal('x,y\r\n1,2\r\n3,4\r\n"5,6",7\r\nNULL,NULL\r\nhttp://gethue.com,http://gethue.com\r\n', content)
|
|
assert_equal('x,y\r\n1,2\r\n3,4\r\n"5,6",7\r\nNULL,NULL\r\nhttp://gethue.com,http://gethue.com\r\n', content)
|
|
|
assert_equal('attachment; filename="foo.csv"', response["content-disposition"])
|
|
assert_equal('attachment; filename="foo.csv"', response["content-disposition"])
|
|
|
|
|
|
|
|
|
|
+ # Check non-ASCII for any browser except FF or no browser info
|
|
|
|
|
+ generator = create_generator(content_generator(headers, data), "csv")
|
|
|
|
|
+ response = make_response(generator, "csv", u'gんtbhんjk?¥n')
|
|
|
|
|
+ assert_equal("application/csv", response["content-type"])
|
|
|
|
|
+ content = ''.join(response.streaming_content)
|
|
|
|
|
+ assert_equal('x,y\r\n1,2\r\n3,4\r\n"5,6",7\r\nNULL,NULL\r\nhttp://gethue.com,http://gethue.com\r\n', content)
|
|
|
|
|
+ assert_equal('attachment; filename="g%E3%82%93tbh%E3%82%93jk%EF%BC%9F%EF%BF%A5n.csv"', response["content-disposition"])
|
|
|
|
|
+
|
|
|
|
|
+ # Check non-ASCII for FF browser
|
|
|
|
|
+ generator = create_generator(content_generator(headers, data), "csv")
|
|
|
|
|
+ response = make_response(generator, "csv", u'gんtbhんjk?¥n',
|
|
|
|
|
+ user_agent='Mozilla / 5.0(Macintosh; Intel Mac OS X 10.12;rv:59.0) Gecko / 20100101 Firefox / 59.0)')
|
|
|
|
|
+ assert_equal("application/csv", response["content-type"])
|
|
|
|
|
+ content = ''.join(response.streaming_content)
|
|
|
|
|
+ assert_equal('x,y\r\n1,2\r\n3,4\r\n"5,6",7\r\nNULL,NULL\r\nhttp://gethue.com,http://gethue.com\r\n', content)
|
|
|
|
|
+ assert_equal('attachment; filename*="g%E3%82%93tbh%E3%82%93jk%EF%BC%9F%EF%BF%A5n.csv"',
|
|
|
|
|
+ response["content-disposition"])
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def test_export_xls():
|
|
def test_export_xls():
|
|
|
headers = ["x", "y"]
|
|
headers = ["x", "y"]
|