Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
telecom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
telecom
Commits
424bc3c6
Commit
424bc3c6
authored
May 16, 2017
by
Roque Porchetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updating unit tests.
parent
9f3496c4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
18 deletions
+56
-18
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/unit_test_external.xml
...sionTemplateItem/portal_components/unit_test_external.xml
+24
-3
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.wendelin.testDataIngestion.py
...portal_components/test.erp5.wendelin.testDataIngestion.py
+31
-14
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.wendelin.testDataIngestion.xml
...ortal_components/test.erp5.wendelin.testDataIngestion.xml
+1
-1
No files found.
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/unit_test_external.xml
View file @
424bc3c6
...
@@ -6,6 +6,12 @@
...
@@ -6,6 +6,12 @@
</pickle>
</pickle>
<pickle>
<pickle>
<dictionary>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<item>
<key>
<string>
default_reference
</string>
</key>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
unit_test_external
</string>
</value>
<value>
<string>
unit_test_external
</string>
</value>
...
@@ -53,13 +59,28 @@
...
@@ -53,13 +59,28 @@
<item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<key>
<string>
workflow_history
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
</pickle>
...
@@ -72,7 +93,7 @@
...
@@ -72,7 +93,7 @@
<item>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
</value>
</value>
</item>
</item>
</dictionary>
</dictionary>
...
@@ -81,7 +102,7 @@
...
@@ -81,7 +102,7 @@
</dictionary>
</dictionary>
</pickle>
</pickle>
</record>
</record>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
</pickle>
...
...
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.wendelin.testDataIngestion.py
View file @
424bc3c6
...
@@ -5,11 +5,17 @@ import time
...
@@ -5,11 +5,17 @@ import time
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
numpy
as
np
import
numpy
as
np
import
math
import
math
import
base64
class
TestDataIngestion
(
SecurityTestCase
):
class
TestDataIngestion
(
SecurityTestCase
):
PART
=
".
PART
"
PART
=
".
xxx
"
EOF
=
".EOF"
EOF
=
".EOF"
FIF
=
".fif"
REF_PREFIX
=
"fake-supplier.fake-dataset."
INGESTION_SCRIPT
=
'HandleFifEmbulkIngestion'
USER
=
'zope'
PASS
=
'roque5'
def
getTitle
(
self
):
def
getTitle
(
self
):
return
"DataIngestionTest"
return
"DataIngestionTest"
...
@@ -23,7 +29,13 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -23,7 +29,13 @@ class TestDataIngestion(SecurityTestCase):
def
getRandomReference
(
self
):
def
getRandomReference
(
self
):
random_string
=
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
xrange
(
10
)])
random_string
=
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
_
in
xrange
(
10
)])
return
'UNIT_TEST-'
+
random_string
return
'UNIT-TEST-'
+
random_string
def
getIngestionReference
(
self
,
reference
):
return
self
.
REF_PREFIX
+
reference
+
self
.
FIF
def
sanitizeReference
(
self
,
reference
):
return
reference
.
replace
(
"."
,
"_"
)
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
):
...
@@ -46,11 +58,12 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -46,11 +58,12 @@ class TestDataIngestion(SecurityTestCase):
return
ingestion_policy
return
ingestion_policy
def
ingestRequest
(
self
,
requestMethod
,
authentication
,
reference
,
eof
,
data_chunk
,
ingestion
):
def
ingestRequest
(
self
,
requestMethod
,
authentication
,
reference
,
eof
,
data_chunk
,
ingestion
):
encoded_data_chunk
=
base64
.
b64encode
(
data_chunk
)
request
=
self
.
portal
.
REQUEST
request
=
self
.
portal
.
REQUEST
request
.
method
=
requestMethod
request
.
method
=
requestMethod
request
.
auth
=
authentication
request
.
auth
=
authentication
request
.
set
(
'reference'
,
reference
+
eof
)
request
.
set
(
'reference'
,
reference
+
eof
)
request
.
set
(
'data_chunk'
,
data_chunk
)
request
.
set
(
'data_chunk'
,
encoded_
data_chunk
)
ingestion
.
ingest
()
ingestion
.
ingest
()
self
.
tic
()
self
.
tic
()
return
return
...
@@ -64,12 +77,12 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -64,12 +77,12 @@ class TestDataIngestion(SecurityTestCase):
def
getDataArray
(
self
,
reference
):
def
getDataArray
(
self
,
reference
):
data_array
=
self
.
portal
.
portal_catalog
.
getResultValue
(
data_array
=
self
.
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Data Array'
,
portal_type
=
'Data Array'
,
reference
=
"Transform Raw FIF Data-"
+
reference
)
reference
=
reference
)
return
data_array
return
data_array
def
manuallyStopIngestionWorkaround
(
self
,
reference
):
def
manuallyStopIngestionWorkaround
(
self
,
reference
):
now
=
DateTime
().
strftime
(
'%Y%m%d'
)
now
=
DateTime
().
strftime
(
'%Y%m%d'
)
data_ingestion_id
=
"%s
-%s"
%
(
now
,
reference
)
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
)
if
data_ingestion
.
getSimulationState
()
==
"started"
:
if
data_ingestion
.
getSimulationState
()
==
"started"
:
...
@@ -91,30 +104,34 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -91,30 +104,34 @@ class TestDataIngestion(SecurityTestCase):
def
test_full_data_ingestion
(
self
):
def
test_full_data_ingestion
(
self
):
reference
=
self
.
getRandomReference
()
reference
=
self
.
getRandomReference
()
ingestion_policy
=
self
.
getIngestionPolicy
(
reference
,
'HandleFifEmbulkIngestion'
)
ingestion_policy
=
self
.
getIngestionPolicy
(
reference
,
self
.
INGESTION_SCRIPT
)
data_chunk
,
nparray
=
self
.
generateRawDataBytesAndArray
()
data_chunk
,
nparray
=
self
.
generateRawDataBytesAndArray
()
self
.
ingestRequest
(
'POST'
,
(
'zope'
,
'roque5'
),
reference
,
self
.
EOF
,
data_chunk
,
ingestion_policy
)
ingestion_reference
=
self
.
getIngestionReference
(
reference
)
data_stream
=
self
.
getDataStream
(
reference
)
self
.
ingestRequest
(
'POST'
,
(
self
.
USER
,
self
.
PASS
),
ingestion_reference
,
self
.
EOF
,
data_chunk
,
ingestion_policy
)
ingestion_reference
=
self
.
sanitizeReference
(
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
(
reference
)
self
.
simulateIngestionAlarm
(
ingestion_
reference
)
data_array
=
self
.
getDataArray
(
reference
)
data_array
=
self
.
getDataArray
(
ingestion_
reference
)
self
.
assertTrue
(
np
.
allclose
(
nparray
,
data_array
.
getArray
()))
self
.
assertTrue
(
np
.
allclose
(
nparray
,
data_array
.
getArray
()))
def
test_data_ingestion_splitted_file
(
self
):
def
test_data_ingestion_splitted_file
(
self
):
reference
=
self
.
getRandomReference
()
reference
=
self
.
getRandomReference
()
ingestion_policy
=
self
.
getIngestionPolicy
(
reference
,
'HandleFifEmbulkIngestion'
)
ingestion_policy
=
self
.
getIngestionPolicy
(
reference
,
self
.
INGESTION_SCRIPT
)
data_chunk
,
nparray
=
self
.
generateRawDataBytesAndArray
()
data_chunk
,
nparray
=
self
.
generateRawDataBytesAndArray
()
data_chunk_1
=
data_chunk
[:
int
(
math
.
floor
(
len
(
data_chunk
)
/
2
))]
data_chunk_1
=
data_chunk
[:
int
(
math
.
floor
(
len
(
data_chunk
)
/
2
))]
data_chunk_2
=
data_chunk
[
int
(
math
.
floor
(
len
(
data_chunk
)
/
2
)):]
data_chunk_2
=
data_chunk
[
int
(
math
.
floor
(
len
(
data_chunk
)
/
2
)):]
ingestion_reference
=
self
.
getIngestionReference
(
reference
)
self
.
ingestRequest
(
'POST'
,
(
'zope'
,
'roque5'
),
reference
,
self
.
PART
,
data_chunk_1
,
ingestion_policy
)
self
.
ingestRequest
(
'POST'
,
(
self
.
USER
,
self
.
PASS
),
ingestion_reference
,
self
.
PART
,
data_chunk_1
,
ingestion_policy
)
data_stream
=
self
.
getDataStream
(
reference
)
self
.
ingestRequest
(
'POST'
,
(
self
.
USER
,
self
.
PASS
),
ingestion_reference
,
self
.
EOF
,
data_chunk_2
,
ingestion_policy
)
self
.
ingestRequest
(
'POST'
,
(
'zope'
,
'roque5'
),
reference
,
self
.
EOF
,
data_chunk_2
,
ingestion_policy
)
ingestion_reference
=
self
.
sanitizeReference
(
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
())
...
...
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.wendelin.testDataIngestion.xml
View file @
424bc3c6
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W:1
11
, 16: Unused variable \'nparray\' (unused-variable)
</string>
<string>
W:1
26
, 16: Unused variable \'nparray\' (unused-variable)
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</item>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment