Commit efe1d9d0 authored by Roque Porchetto's avatar Roque Porchetto

erp5_wendelin_telecom_ingestion: portal components refactoring

- test and extensions ids changed to mandatory format
- unit tests refactored according to last changes
parent d6c8111f
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>external_process_raw_data</string> </value> <value> <string>extension.erp5.external_process_raw_data</string> </value>
</item> </item>
<item> <item>
<key> <string>language</string> </key> <key> <string>language</string> </key>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>extension.erp5.ingestion.log</string> </value> <value> <string>extension.erp5.ingestion_log</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>unit_test_external</string> </value> <value> <string>extension.erp5.unit_test_external</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
......
...@@ -36,7 +36,7 @@ class TestDataIngestion(SecurityTestCase): ...@@ -36,7 +36,7 @@ class TestDataIngestion(SecurityTestCase):
return self.REF_PREFIX + reference + self.FIF return self.REF_PREFIX + reference + self.FIF
def sanitizeReference(self, reference): def sanitizeReference(self, reference):
return reference.replace(".", "_") return reference.replace(".", "_"), '_'.join(reference.split('.')[1:])
def chunks(self, l, n): def chunks(self, l, n):
for i in xrange(0, len(l), n): for i in xrange(0, len(l), n):
...@@ -81,8 +81,7 @@ class TestDataIngestion(SecurityTestCase): ...@@ -81,8 +81,7 @@ class TestDataIngestion(SecurityTestCase):
reference = reference) reference = reference)
return data_array return data_array
def manuallyStopIngestionWorkaround(self, reference): def manuallyStopIngestionWorkaround(self, reference, now):
now = DateTime().strftime('%Y%m%d')
data_ingestion_id = "%s_%s" %(reference, now) data_ingestion_id = "%s_%s" %(reference, now)
url = 'data_ingestion_module/' + data_ingestion_id url = 'data_ingestion_module/' + data_ingestion_id
data_ingestion = self.context.restrictedTraverse(url) data_ingestion = self.context.restrictedTraverse(url)
...@@ -90,10 +89,10 @@ class TestDataIngestion(SecurityTestCase): ...@@ -90,10 +89,10 @@ class TestDataIngestion(SecurityTestCase):
data_ingestion.stop() data_ingestion.stop()
self.tic() self.tic()
def simulateIngestionAlarm(self, reference): def simulateIngestionAlarm(self, reference, now):
self.portal.ERP5Site_stopIngestionList() self.portal.ERP5Site_stopIngestionList()
self.tic() self.tic()
self.manuallyStopIngestionWorkaround(reference) self.manuallyStopIngestionWorkaround(reference, now)
self.portal.ERP5Site_createDataAnalysisList() self.portal.ERP5Site_createDataAnalysisList()
time.sleep(5) time.sleep(5)
...@@ -109,13 +108,14 @@ class TestDataIngestion(SecurityTestCase): ...@@ -109,13 +108,14 @@ class TestDataIngestion(SecurityTestCase):
data_chunk, nparray = self.generateRawDataBytesAndArray() data_chunk, nparray = self.generateRawDataBytesAndArray()
ingestion_reference = self.getIngestionReference(reference) ingestion_reference = self.getIngestionReference(reference)
now = DateTime().strftime('%Y%m%d-%H%M%S')
self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.EOF, data_chunk, ingestion_policy) self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.EOF, data_chunk, ingestion_policy)
ingestion_reference = self.sanitizeReference(ingestion_reference) ingestion_id, ingestion_reference = self.sanitizeReference(ingestion_reference)
data_stream = self.getDataStream(ingestion_reference) data_stream = self.getDataStream(ingestion_reference)
self.assertEqual(len(data_chunk), len(data_stream.getData())) self.assertEqual(len(data_chunk), len(data_stream.getData()))
self.assertEqual(data_chunk, data_stream.getData()) self.assertEqual(data_chunk, data_stream.getData())
self.simulateIngestionAlarm(ingestion_reference) self.simulateIngestionAlarm(ingestion_id, now)
data_array = self.getDataArray(ingestion_reference) data_array = self.getDataArray(ingestion_reference)
self.assertTrue(np.allclose(nparray, data_array.getArray())) self.assertTrue(np.allclose(nparray, data_array.getArray()))
...@@ -131,7 +131,7 @@ class TestDataIngestion(SecurityTestCase): ...@@ -131,7 +131,7 @@ class TestDataIngestion(SecurityTestCase):
self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.PART, data_chunk_1, ingestion_policy) self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.PART, data_chunk_1, ingestion_policy)
self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.EOF, data_chunk_2, ingestion_policy) self.ingestRequest('POST', (self.USER, self.PASS), ingestion_reference, self.EOF, data_chunk_2, ingestion_policy)
ingestion_reference = self.sanitizeReference(ingestion_reference) ingestion_id, ingestion_reference = self.sanitizeReference(ingestion_reference)
data_stream = self.getDataStream(ingestion_reference) data_stream = self.getDataStream(ingestion_reference)
self.assertEqual(len(data_chunk), len(data_stream.getData())) self.assertEqual(len(data_chunk), len(data_stream.getData()))
self.assertEqual(data_chunk, data_stream.getData()) self.assertEqual(data_chunk, data_stream.getData())
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>test.erp5.wendelin.testDataIngestion</string> </value> <value> <string>test.erp5.testDataIngestion</string> </value>
</item> </item>
<item> <item>
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
<key> <string>text_content_warning_message</string> </key> <key> <string>text_content_warning_message</string> </key>
<value> <value>
<tuple> <tuple>
<string>W:134, 4: Unused variable \'ingestion_id\' (unused-variable)</string>
<string>W:127, 16: Unused variable \'nparray\' (unused-variable)</string> <string>W:127, 16: Unused variable \'nparray\' (unused-variable)</string>
<string>W: 9, 0: Unused log imported from Products.ERP5Type.Log (unused-import)</string> <string>W: 9, 0: Unused log imported from Products.ERP5Type.Log (unused-import)</string>
</tuple> </tuple>
......
external_process_raw_data extension.erp5.external_process_raw_data
unit_test_external extension.erp5.unit_test_external
extension.erp5.ingestion.log extension.erp5.ingestion_log
\ No newline at end of file \ No newline at end of file
test.erp5.wendelin.testDataIngestion test.erp5.testDataIngestion
\ No newline at end of file \ No newline at end of file
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