Commit 70f1cb31 authored by Ivan Tyagov's avatar Ivan Tyagov

Generate Dynamically Data Supply for test.

parent 93fc04b6
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Add a data supply structure for a data ingestion on a portal ingestion policy.\n
"""\n
data_supply = context.data_supply_module.newContent( \\\n
portal_type=\'Data Supply\', **data_supply_kw)\n
data_supply.validate()\n
\n
# add default line\n
data_supply_line = data_supply.newContent(portal_type=\'Data Supply Line\', \\\n
**data_supply_line_kw)\n
\n
return data_supply\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>data_supply_kw, data_supply_line_kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PortalIngestionPolicy_addDataSupply</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime
import msgpack import msgpack
import numpy as np import numpy as np
import string import string
...@@ -60,6 +61,7 @@ class Test(ERP5TypeTestCase): ...@@ -60,6 +61,7 @@ class Test(ERP5TypeTestCase):
Test ingestion using a POST Request containing a msgpack encoded message Test ingestion using a POST Request containing a msgpack encoded message
simulating input from fluentd simulating input from fluentd
""" """
now = DateTime()
portal = self.portal portal = self.portal
request = portal.REQUEST request = portal.REQUEST
...@@ -71,19 +73,32 @@ class Test(ERP5TypeTestCase): ...@@ -71,19 +73,32 @@ class Test(ERP5TypeTestCase):
request.set('reference', 'car') request.set('reference', 'car')
request.set('data_chunk', data_chunk) request.set('data_chunk', data_chunk)
ingestion_policy = portal.portal_ingestion_policies.wendelin_car_logs
# create new Data Stream for test purposes # create new Data Stream for test purposes
data_stream = portal.data_stream_module.newContent( \ data_stream = portal.data_stream_module.newContent( \
portal_type='Data Stream', \ portal_type='Data Stream', \
reference='car') reference='car')
data_stream.validate() data_stream.validate()
# asssign it to Data Supply (XXX add dynamically needed test structure in step) # create Data Supply
data_supply_line = portal.restrictedTraverse('data_supply_module/wendelin_3/1') resource = portal.restrictedTraverse('data_product_module/wendelin_4')
data_supply_line.setDestinationSectionValue(data_stream) sensor = portal.restrictedTraverse('sensor_module/wendelin_1')
data_supply_kw = {'reference': 'car',
'version': '001',
'start_date': now,
'stop_date': now + 365}
data_supply_line_kw = {'resource_value': resource,
'source_section_value': sensor,
'destination_section_value': data_stream}
data_supply = ingestion_policy.PortalIngestionPolicy_addDataSupply( \
data_supply_kw, \
data_supply_line_kw)
self.tic() self.tic()
# do real ingestion call # do real ingestion call
portal.portal_ingestion_policies.wendelin_car_logs.ingest() ingestion_policy.ingest()
# ingestion handler script saves new data using new line so we # ingestion handler script saves new data using new line so we
# need to remove it, it also stringifies thus we need to # need to remove it, it also stringifies thus we need to
......
...@@ -46,10 +46,11 @@ ...@@ -46,10 +46,11 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 54, 4: Unused variable \'scipy\' (unused-variable)</string> <string>W: 55, 4: Unused variable \'scipy\' (unused-variable)</string>
<string>W: 56, 4: Unused variable \'pandas\' (unused-variable)</string> <string>W: 57, 4: Unused variable \'pandas\' (unused-variable)</string>
<string>W: 55, 4: Unused variable \'sklearn\' (unused-variable)</string> <string>W: 56, 4: Unused variable \'sklearn\' (unused-variable)</string>
<string>W: 95, 72: Unused variable \'n\' (unused-variable)</string> <string>W: 95, 4: Unused variable \'data_supply\' (unused-variable)</string>
<string>W:110, 72: Unused variable \'n\' (unused-variable)</string>
</tuple> </tuple>
</value> </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