Commit 702276a6 authored by Nicolas Delaby's avatar Nicolas Delaby

* According RFC 2183 about Content-Disposition,

its preferable to return binary content as attachment.
* import http response CODE from httplib


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35392 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2807d723
...@@ -33,8 +33,9 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -33,8 +33,9 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Form.Selection import Selection from Products.ERP5Form.Selection import Selection
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Products.ERP5OOo.tests.utils import Validator from Products.ERP5OOo.tests.utils import Validator
import httplib
HTTP_OK = 200 HTTP_OK = httplib.OK
# setting this to True allows the .publish() calls to provide tracebacks # setting this to True allows the .publish() calls to provide tracebacks
debug = False debug = False
...@@ -113,7 +114,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -113,7 +114,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_list_domain_tree(self): def test_form_list_domain_tree(self):
...@@ -133,7 +134,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -133,7 +134,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view(self): def test_form_view(self):
...@@ -146,7 +147,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -146,7 +147,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_empty_listbox(self): def test_form_view_empty_listbox(self):
...@@ -160,7 +161,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -160,7 +161,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_non_empty_listbox(self): def test_form_view_non_empty_listbox(self):
...@@ -172,7 +173,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -172,7 +173,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_format(self): def test_form_view_format(self):
...@@ -184,7 +185,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -184,7 +185,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_report_view_form_view(self): def test_report_view_form_view(self):
...@@ -197,7 +198,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -197,7 +198,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_report_view_form_list(self): def test_report_view_form_list(self):
...@@ -216,7 +217,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -216,7 +217,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
...@@ -228,7 +229,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -228,7 +229,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_report_view_sheet_per_report_section(self): def test_report_view_sheet_per_report_section(self):
...@@ -239,7 +240,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -239,7 +240,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_encoding(self): def test_form_view_encoding(self):
...@@ -250,7 +251,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -250,7 +251,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_category(self): def test_form_view_category(self):
...@@ -261,7 +262,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -261,7 +262,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_broken_category(self): def test_form_view_broken_category(self):
...@@ -273,7 +274,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -273,7 +274,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_view_embedded_image(self): def test_form_view_embedded_image(self):
...@@ -284,7 +285,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -284,7 +285,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
# without image # without image
response = self.publish('/%s/person_module/pers_without_image/Person_viewDetails' response = self.publish('/%s/person_module/pers_without_image/Person_viewDetails'
...@@ -293,7 +294,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -293,7 +294,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_report_view_encoding(self): def test_report_view_encoding(self):
...@@ -304,7 +305,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -304,7 +305,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_form_list_encoding(self): def test_form_list_encoding(self):
...@@ -316,7 +317,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -316,7 +317,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_image_field_form_view(self): def test_image_field_form_view(self):
...@@ -328,7 +329,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -328,7 +329,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_image_field_form_view_bottom_group(self): def test_image_field_form_view_bottom_group(self):
...@@ -341,7 +342,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -341,7 +342,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
self._validate(response.getBody()) self._validate(response.getBody())
def test_textarea_center_group(self): def test_textarea_center_group(self):
...@@ -356,7 +357,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -356,7 +357,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
content_type = response.getHeader('content-type') content_type = response.getHeader('content-type')
self.assertTrue(content_type.startswith(self.content_type), content_type) self.assertTrue(content_type.startswith(self.content_type), content_type)
content_disposition = response.getHeader('content-disposition') content_disposition = response.getHeader('content-disposition')
self.assertEquals('inline', content_disposition.split(';')[0]) self.assertEquals('attachment', content_disposition.split(';')[0])
body = response.getBody() body = response.getBody()
self._validate(body) self._validate(body)
......
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