Commit 1595f4e4 authored by Jérome Perrin's avatar Jérome Perrin

test: adjust self.publish() tests for Zope4

self.publish() had a bug regarding status code for empty responses on
Zope2 and that bug was fixed in Zope4, this adjust the code to support
both versions.
parent 488306a5
Pipeline #26886 failed with stage
in 0 seconds
......@@ -22,6 +22,7 @@
from cStringIO import StringIO
import binascii
from httplib import NO_CONTENT
import msgpack
import numpy as np
import string
......@@ -36,6 +37,14 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPythonScript
from wendelin.bigarray.array_zodb import ZBigArray
from App.version_txt import getZopeVersion
if getZopeVersion() < (4, ): # BBB Zope2
# Zope set http status code 204 for empty response, but
# on Zope 2 this is not correctly reflected in ERP5TypeTestCase.publish,
# for such responses the status is set to 200 (but for "real" requests
# it is set to 204, this only affected the testing)
NO_CONTENT = 200
def getRandomString():
return 'test_%s' %''.join([random.choice(string.ascii_letters + string.digits) \
......@@ -97,12 +106,7 @@ class Test(ERP5TypeTestCase):
publish_kw = dict(user='ERP5TypeTestCase', env=env,
request_method='POST', stdin=StringIO(body))
response = self.publish(path, **publish_kw)
# Due to inconsistencies in the Zope framework,
# a normal instance returns 204. As explained at
# http://blog.ploeh.dk/2013/04/30/rest-lesson-learned-avoid-204-responses/
# turning 200 into 204 automatically when the body is empty is questionable.
self.assertEqual(200, response.getStatus())
self.assertEqual(NO_CONTENT, response.getStatus())
# at every ingestion if no specialised Data Ingestion exists it is created
# thus it is needed to wait for server side activities to be processed
self.tic()
......@@ -388,7 +392,7 @@ class Test(ERP5TypeTestCase):
request_method='POST', stdin=StringIO(body))
response = self.publish(path, **publish_kw)
self.assertEqual(200, response.getStatus())
self.assertEqual(NO_CONTENT, response.getStatus())
self.tic()
......
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