Commit 9fa5088a authored by Ivan Tyagov's avatar Ivan Tyagov

Make test stand alone.

parent 34dc75cf
...@@ -32,6 +32,10 @@ import numpy as np ...@@ -32,6 +32,10 @@ import numpy as np
import string import string
import random import random
def getRandomString():
return 'test_%s' %''.join([random.choice(string.ascii_letters + string.digits) \
for n in xrange(32)])
class Test(ERP5TypeTestCase): class Test(ERP5TypeTestCase):
""" """
Wendelin Test Wendelin Test
...@@ -66,32 +70,43 @@ class Test(ERP5TypeTestCase): ...@@ -66,32 +70,43 @@ class Test(ERP5TypeTestCase):
request = portal.REQUEST request = portal.REQUEST
# simulate fluentd by setting proper values in REQUEST # simulate fluentd by setting proper values in REQUEST
reference = getRandomString()
number_list = range(11) number_list = range(11)
request.method = 'POST' request.method = 'POST'
real_data = ('%s\n' %','.join([str(x) for x in number_list]))*10000 real_data = ('%s\n' %','.join([str(x) for x in number_list]))*10000
data_chunk = msgpack.packb([0, real_data], use_bin_type=True) data_chunk = msgpack.packb([0, real_data], use_bin_type=True)
request.set('reference', 'car') request.set('reference', reference)
request.set('data_chunk', data_chunk) request.set('data_chunk', data_chunk)
ingestion_policy = portal.portal_ingestion_policies.wendelin_car_logs # create ingestion policy
ingestion_policy = portal.portal_ingestion_policies.newContent( \
portal_type ='Ingestion Policy',
reference = reference,
version = '001',
script_id = 'ERP5Site_handleDefaultFluentdIngestion')
ingestion_policy.validate()
# create sensor
sensor = portal.sensor_module.newContent( \
portal_type='Sensor',
reference = reference)
sensor.validate()
# 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=reference)
data_stream.validate() data_stream.validate()
# create Data Supply # create Data Supply
resource = portal.restrictedTraverse('data_product_module/wendelin_4') resource = portal.restrictedTraverse('data_product_module/wendelin_4')
sensor = portal.restrictedTraverse('sensor_module/wendelin_1') data_supply_kw = {'reference': reference,
data_supply_kw = {'reference': 'car',
'version': '001', 'version': '001',
'start_date': now, 'start_date': now,
'stop_date': now + 365} 'stop_date': now + 365}
data_supply_line_kw = {'resource_value': resource, data_supply_line_kw = {'resource_value': resource,
'source_section_value': sensor, 'source_section_value': sensor,
'destination_section_value': data_stream} 'destination_section_value': data_stream}
data_supply = ingestion_policy.PortalIngestionPolicy_addDataSupply( \ data_supply = ingestion_policy.PortalIngestionPolicy_addDataSupply( \
data_supply_kw, \ data_supply_kw, \
data_supply_line_kw) data_supply_line_kw)
...@@ -106,8 +121,7 @@ class Test(ERP5TypeTestCase): ...@@ -106,8 +121,7 @@ class Test(ERP5TypeTestCase):
self.assertEqual('\n%s' %real_data, data_stream_data) # XXX: get rid of new line in ingest script! self.assertEqual('\n%s' %real_data, data_stream_data) # XXX: get rid of new line in ingest script!
# try sample transformation # try sample transformation
reference = 'test-data-array- %s' \ reference = 'test-data-array- %s' %getRandomString()
%''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)])
data_array = portal.data_array_module.newContent( data_array = portal.data_array_module.newContent(
portal_type='Data Array', portal_type='Data Array',
......
...@@ -46,11 +46,11 @@ ...@@ -46,11 +46,11 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W: 55, 4: Unused variable \'scipy\' (unused-variable)</string> <string>W: 37, 8: Unused variable \'n\' (unused-variable)</string>
<string>W: 57, 4: Unused variable \'pandas\' (unused-variable)</string> <string>W: 59, 4: Unused variable \'scipy\' (unused-variable)</string>
<string>W: 56, 4: Unused variable \'sklearn\' (unused-variable)</string> <string>W: 61, 4: Unused variable \'pandas\' (unused-variable)</string>
<string>W: 95, 4: Unused variable \'data_supply\' (unused-variable)</string> <string>W: 60, 4: Unused variable \'sklearn\' (unused-variable)</string>
<string>W:110, 72: Unused variable \'n\' (unused-variable)</string> <string>W:110, 4: Unused variable \'data_supply\' (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