Commit 17800924 authored by Julien Muchembled's avatar Julien Muchembled

fixup! fixup! IngestionPolicy: accept data chunk as application/octet-stream

parent d97f39bc
...@@ -29,9 +29,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase ...@@ -29,9 +29,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from wendelin.bigarray.array_zodb import ZBigArray from wendelin.bigarray.array_zodb import ZBigArray
from DateTime import DateTime from DateTime import DateTime
from zExceptions import NotFound
from cStringIO import StringIO from cStringIO import StringIO
import httplib
import msgpack import msgpack
import numpy as np import numpy as np
import string import string
...@@ -113,10 +111,15 @@ class Test(ERP5TypeTestCase): ...@@ -113,10 +111,15 @@ class Test(ERP5TypeTestCase):
body = urllib.urlencode({'data_chunk': body}) body = urllib.urlencode({'data_chunk': body})
else: else:
env = {'CONTENT_TYPE': 'application/octet-stream'} env = {'CONTENT_TYPE': 'application/octet-stream'}
response = self.publish( path = ingestion_policy.getPath() + '/ingest?reference=' + reference
ingestion_policy.getPath() + '/ingest?reference=' + reference, publish_kw = dict(basic='ERP5TypeTestCase:', env=env,
'ERP5TypeTestCase:', env, request_method='POST', stdin=StringIO(body)) request_method='POST', stdin=StringIO(body))
self.assertEqual(httplib.NO_CONTENT, response.getStatus()) 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())
data_stream_data = data_stream.getData() data_stream_data = data_stream.getData()
self.assertEqual(real_data, data_stream_data) self.assertEqual(real_data, data_stream_data)
...@@ -135,8 +138,8 @@ class Test(ERP5TypeTestCase): ...@@ -135,8 +138,8 @@ class Test(ERP5TypeTestCase):
self.assertTrue(np.array_equal(zarray, np.arange(100001))) self.assertTrue(np.array_equal(zarray, np.arange(100001)))
# test ingesting with bad reference and raise of NotFound # test ingesting with bad reference and raise of NotFound
request.set('reference', reference + 'not_existing') response = self.publish(path + '_not_existing', **publish_kw)
self.assertRaises(NotFound, ingestion_policy.ingest) self.assertEqual(404, response.getStatus())
def test_01_1_IngestionFromOldFluentd(self): def test_01_1_IngestionFromOldFluentd(self):
self.test_01_IngestionFromFluentd(True) self.test_01_IngestionFromFluentd(True)
......
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