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
155cc943
Commit
155cc943
authored
Jul 28, 2018
by
Roque Porchetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin_telecom_ingestion: update unit tests
parent
0f36ef03
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
47 deletions
+33
-47
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.py
...al_components/extension.erp5.external_process_raw_data.py
+1
-1
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.unit_test_external.py
...em/portal_components/extension.erp5.unit_test_external.py
+23
-13
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.unit_test_external.xml
...m/portal_components/extension.erp5.unit_test_external.xml
+1
-3
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.testDataIngestion.py
...lateItem/portal_components/test.erp5.testDataIngestion.py
+6
-28
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.testDataIngestion.xml
...ateItem/portal_components/test.erp5.testDataIngestion.xml
+2
-2
No files found.
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.external_process_raw_data.py
View file @
155cc943
...
@@ -73,7 +73,7 @@ def processFifData(file_name, data_array, data_descriptor):
...
@@ -73,7 +73,7 @@ def processFifData(file_name, data_array, data_descriptor):
try
:
try
:
html_report
=
getHTMLReport
(
file_name
,
raw
)
html_report
=
getHTMLReport
(
file_name
,
raw
)
data_descriptor
.
setTextContent
(
html_report
)
data_descriptor
.
setTextContent
(
html_report
)
log
(
"Data Descritor content saved"
)
log
(
"Data Descri
p
tor content saved"
)
except
Exception
as
e
:
except
Exception
as
e
:
log
(
"Error handling Data Descriptor content: "
+
str
(
e
))
log
(
"Error handling Data Descriptor content: "
+
str
(
e
))
...
...
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.unit_test_external.py
View file @
155cc943
import
transaction
import
time
import
mne
import
mne
import
os
import
numpy
as
np
from
Products.ERP5Type.Log
import
log
def
generateRawData
(
array
):
def
generateRawData
(
sample_data_stream
):
info
=
mne
.
create_info
(
log
(
"-TEST- Getting raw content from sample data stream..."
)
ch_names
=
[
'MEG1'
,
'MEG2'
,
'EEG1'
,
'EEG2'
,
'EOG'
],
content
=
sample_data_stream
.
getData
()
ch_types
=
[
'grad'
,
'grad'
,
'eeg'
,
'eeg'
,
'eog'
],
file_name
=
"sample_data_stream_raw.fif"
sfreq
=
100
)
with
open
(
file_name
,
'wb'
)
as
fif_file
:
info
=
mne
.
create_info
(
array
.
shape
[
0
],
array
.
shape
[
1
])
fif_file
.
write
(
content
)
raw
=
mne
.
io
.
RawArray
(
array
,
info
)
raw
=
mne
.
io
.
read_raw_fif
(
file_name
)
raw
.
save
(
"test_raw_data.fif"
,
overwrite
=
True
)
with
open
(
"test_raw_data.fif"
,
"rb"
)
as
file
:
log
(
"-TEST- Generating array from raw content..."
)
content
=
file
.
read
()
picks
=
mne
.
pick_types
(
raw
.
info
)
return
content
data
,
times
=
raw
[
picks
]
array
=
np
.
zeros
(
data
.
shape
)
for
pick
in
xrange
(
0
,
len
(
picks
)):
data
,
times
=
raw
[
pick
]
array
[
pick
]
=
data
[
0
]
if
os
.
path
.
exists
(
file_name
):
os
.
remove
(
file_name
)
log
(
"-TEST- Done."
)
return
content
,
array
bt5/erp5_wendelin_telecom_ingestion/ExtensionTemplateItem/portal_components/extension.erp5.unit_test_external.xml
View file @
155cc943
...
@@ -52,9 +52,7 @@
...
@@ -52,9 +52,7 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W: 13, 42: Redefining built-in \'file\' (redefined-builtin)
</string>
<string>
W: 16, 8: Unused variable \'times\' (unused-variable)
</string>
<string>
W: 1, 0: Unused import transaction (unused-import)
</string>
<string>
W: 2, 0: Unused import time (unused-import)
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</item>
...
...
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.testDataIngestion.py
View file @
155cc943
...
@@ -43,8 +43,9 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -43,8 +43,9 @@ class TestDataIngestion(SecurityTestCase):
yield
l
[
i
:
i
+
n
]
yield
l
[
i
:
i
+
n
]
def
generateRawDataBytesAndArray
(
self
):
def
generateRawDataBytesAndArray
(
self
):
array
=
np
.
random
.
randn
(
5
,
1000
)
url
=
'data_stream_module/mne_sample_for_test'
raw_data
=
self
.
context
.
generateRawData
(
array
)
sample_data_stream
=
self
.
context
.
restrictedTraverse
(
url
)
raw_data
,
array
=
self
.
context
.
generateRawData
(
sample_data_stream
)
return
raw_data
,
array
return
raw_data
,
array
def
getIngestionPolicy
(
self
,
reference
,
ingestion_script
):
def
getIngestionPolicy
(
self
,
reference
,
ingestion_script
):
...
@@ -118,7 +119,9 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -118,7 +119,9 @@ class TestDataIngestion(SecurityTestCase):
self
.
simulateIngestionAlarm
(
ingestion_id
,
now
)
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
()))
np
.
testing
.
assert_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
):
...
@@ -135,28 +138,3 @@ class TestDataIngestion(SecurityTestCase):
...
@@ -135,28 +138,3 @@ class TestDataIngestion(SecurityTestCase):
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
())
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.testDataIngestion.xml
View file @
155cc943
...
@@ -46,8 +46,8 @@
...
@@ -46,8 +46,8 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W:13
4
, 4: Unused variable \'ingestion_id\' (unused-variable)
</string>
<string>
W:13
7
, 4: Unused variable \'ingestion_id\' (unused-variable)
</string>
<string>
W:1
27
, 16: Unused variable \'nparray\' (unused-variable)
</string>
<string>
W:1
30
, 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>
</value>
</value>
...
...
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