Commit 2d56a09d authored by Jérome Perrin's avatar Jérome Perrin

testHalJsonStyle: fix expected CSV content type header

This is forwarded from cloudooo and now that cloudooo use
libreoffice 7 it sets the correct ( according to rfc4180 )
content type for CSV

see https://www.rfc-editor.org/rfc/rfc4180#page-4
parent 0a29d9c1
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import transaction import transaction
from zExceptions import Unauthorized from zExceptions import Unauthorized
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type import IS_ZOPE2
from unittest import skip from unittest import skip
from functools import wraps from functools import wraps
...@@ -3180,7 +3181,10 @@ class TestERP5ODS(ERP5HALJSONStyleSkinsMixin): ...@@ -3180,7 +3181,10 @@ class TestERP5ODS(ERP5HALJSONStyleSkinsMixin):
) )
self.assertEqual(fake_request.get('portal_skin'), 'ODS') self.assertEqual(fake_request.get('portal_skin'), 'ODS')
self.assertEqual(fake_request.RESPONSE.status, 200) self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'application/csv') if IS_ZOPE2:
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv')
else:
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv; charset=utf-8')
expected_csv = 'Title,Creation Date\nfoook2,XX/XX/XXXX XX:XX:XX\nfoook1,XX/XX/XXXX XX:XX:XX\n' expected_csv = 'Title,Creation Date\nfoook2,XX/XX/XXXX XX:XX:XX\nfoook1,XX/XX/XXXX XX:XX:XX\n'
self.assertEqual(len(result), len(expected_csv), result) self.assertEqual(len(result), len(expected_csv), result)
prefix_length = len('Title,Creation Date\nfoook2,') prefix_length = len('Title,Creation Date\nfoook2,')
...@@ -3241,7 +3245,10 @@ class TestERP5ODS(ERP5HALJSONStyleSkinsMixin): ...@@ -3241,7 +3245,10 @@ class TestERP5ODS(ERP5HALJSONStyleSkinsMixin):
) )
self.assertEqual(fake_request.get('portal_skin'), 'ODS') self.assertEqual(fake_request.get('portal_skin'), 'ODS')
self.assertEqual(fake_request.RESPONSE.status, 200) self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'application/csv') if IS_ZOPE2:
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv')
else:
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'), 'text/csv; charset=utf-8')
self.assertTrue('foook1' in result, result) self.assertTrue('foook1' in result, result)
self.assertTrue('foook2' in result, result) self.assertTrue('foook2' in result, result)
self.assertTrue('foonotok' not in result, result) self.assertTrue('foonotok' not in result, result)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment