Commit d40a41cf authored by Ivan Tyagov's avatar Ivan Tyagov

Raise in case of improper server side configuration so sender is aware rather...

Raise in case of improper server side configuration so sender is aware rather than silently return nothing and fool sender it's all ok.
Pylint.
parent ed1e08aa
......@@ -61,13 +61,15 @@
-> Data Stream\n
"""\n
from DateTime import DateTime\n
from zExceptions import NotFound\n
\n
now = DateTime()\n
request = context.REQUEST\n
portal_catalog = context.portal_catalog\n
\n
# keep backwards compatability\n
reference = request.get(\'reference\', request.get(\'input_stream_ref\'))\n
reference = request.get(\'reference\', \\\n
request.get(\'input_stream_ref\'))\n
data_chunk = request.get(\'data_chunk\')\n
\n
# XXX: add start_data and stop_date so all searches are time aware\n
......@@ -124,6 +126,13 @@ if data_chunk is not None and reference is not None:\n
# objects in data_ingestion_module. We can use same approach and same \n
# business process for analytics stage (just different trade_state / phase)?\n
# JP: we should use this approach at a later stage\n
# this approach can be hooked through interaction workflow on data stream\n
else:\n
raise NotFound(\'No data stream configuration found.\') \n
else:\n
raise NotFound(\'No data supply configuration found.\')\n
else:\n
raise NotFound(\'No data or any configuration not found.\')\n
]]></string> </value>
......
......@@ -28,6 +28,7 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
from wendelin.bigarray.array_zodb import ZBigArray
from zExceptions import NotFound
import msgpack
import numpy as np
import string
......@@ -35,7 +36,7 @@ import random
def getRandomString():
return 'test_%s' %''.join([random.choice(string.ascii_letters + string.digits) \
for n in xrange(32)])
for _ in xrange(32)])
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
......@@ -75,9 +76,9 @@ class Test(ERP5TypeTestCase):
Test we can import certain libraries but still failure to do so should be a
a test step failure rather than global test failure.
"""
import scipy
import sklearn
import pandas
import scipy as _
import sklearn as _
import pandas as _
def test_01_IngestionFromFluentd(self):
"""
......@@ -95,7 +96,7 @@ class Test(ERP5TypeTestCase):
# make sure real_data tail is also a full line
real_data += '\n'
ingestion_policy, data_supply, data_stream, data_array = \
ingestion_policy, _, data_stream, data_array = \
self.stepSetupIngestion(reference)
# simulate fluentd by setting proper values in REQUEST
......@@ -121,6 +122,11 @@ class Test(ERP5TypeTestCase):
self.assertEqual(np.average(zarray), np.average(np.arange(100001)))
self.assertTrue(np.array_equal(zarray, np.arange(100001)))
# test ingesting with bad reference and raise of NotFound
request.set('reference', reference + 'not_existing')
self.assertRaises(NotFound, ingestion_policy.ingest)
def test_01_1_IngestionTail(self):
"""
Test real time convertion to a numpy array by appending data to a data stream.
......@@ -135,7 +141,7 @@ class Test(ERP5TypeTestCase):
# make sure real_data tail is also a full line
real_data += '\n'
ingestion_policy, data_supply, data_stream, data_array = self.stepSetupIngestion(reference)
_, _, data_stream, data_array = self.stepSetupIngestion(reference)
data_stream.appendData(real_data)
self.tic()
......@@ -189,7 +195,7 @@ context.activate().DataStream_readChunkListAndTransform( \
offset = max_elements / jobs
start = 0
end = start + offset
for i in range(jobs):
for _ in range(jobs):
# calculate directly expectations
expected_result_list.append(np.average(expected_numpy_array[start:end]))
data_array.activate(
......@@ -219,7 +225,7 @@ context.activate().DataStream_readChunkListAndTransform( \
portal.log( real_data)
ingestion_policy, data_supply, data_stream, data_array = self.stepSetupIngestion(reference)
_, _, data_stream, _ = self.stepSetupIngestion(reference)
data_stream.appendData(real_data)
self.tic()
......
......@@ -45,19 +45,7 @@
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple>
<string>W: 38, 8: Unused variable \'n\' (unused-variable)</string>
<string>W: 78, 4: Unused variable \'scipy\' (unused-variable)</string>
<string>W: 80, 4: Unused variable \'pandas\' (unused-variable)</string>
<string>W: 79, 4: Unused variable \'sklearn\' (unused-variable)</string>
<string>W: 98, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:138, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:192, 8: Unused variable \'i\' (unused-variable)</string>
<string>W:138, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:222, 4: Unused variable \'ingestion_policy\' (unused-variable)</string>
<string>W:222, 22: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:222, 48: Unused variable \'data_array\' (unused-variable)</string>
</tuple>
<tuple/>
</value>
</item>
<item>
......
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