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
Show 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):
try
:
html_report
=
getHTMLReport
(
file_name
,
raw
)
data_descriptor
.
setTextContent
(
html_report
)
log
(
"Data Descritor content saved"
)
log
(
"Data Descri
p
tor content saved"
)
except
Exception
as
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
os
import
numpy
as
np
from
Products.ERP5Type.Log
import
log
def
generateRawData
(
array
):
info
=
mne
.
create_info
(
ch_names
=
[
'MEG1'
,
'MEG2'
,
'EEG1'
,
'EEG2'
,
'EOG'
],
ch_types
=
[
'grad'
,
'grad'
,
'eeg'
,
'eeg'
,
'eog'
],
sfreq
=
100
)
info
=
mne
.
create_info
(
array
.
shape
[
0
],
array
.
shape
[
1
])
raw
=
mne
.
io
.
RawArray
(
array
,
info
)
raw
.
save
(
"test_raw_data.fif"
,
overwrite
=
True
)
with
open
(
"test_raw_data.fif"
,
"rb"
)
as
file
:
content
=
file
.
read
()
return
content
def
generateRawData
(
sample_data_stream
):
log
(
"-TEST- Getting raw content from sample data stream..."
)
content
=
sample_data_stream
.
getData
()
file_name
=
"sample_data_stream_raw.fif"
with
open
(
file_name
,
'wb'
)
as
fif_file
:
fif_file
.
write
(
content
)
raw
=
mne
.
io
.
read_raw_fif
(
file_name
)
log
(
"-TEST- Generating array from raw content..."
)
picks
=
mne
.
pick_types
(
raw
.
info
)
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 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 13, 42: Redefining built-in \'file\' (redefined-builtin)
</string>
<string>
W: 1, 0: Unused import transaction (unused-import)
</string>
<string>
W: 2, 0: Unused import time (unused-import)
</string>
<string>
W: 16, 8: Unused variable \'times\' (unused-variable)
</string>
</tuple>
</value>
</item>
...
...
bt5/erp5_wendelin_telecom_ingestion/TestTemplateItem/portal_components/test.erp5.testDataIngestion.py
View file @
155cc943
...
...
@@ -43,8 +43,9 @@ class TestDataIngestion(SecurityTestCase):
yield
l
[
i
:
i
+
n
]
def
generateRawDataBytesAndArray
(
self
):
array
=
np
.
random
.
randn
(
5
,
1000
)
raw_data
=
self
.
context
.
generateRawData
(
array
)
url
=
'data_stream_module/mne_sample_for_test'
sample_data_stream
=
self
.
context
.
restrictedTraverse
(
url
)
raw_data
,
array
=
self
.
context
.
generateRawData
(
sample_data_stream
)
return
raw_data
,
array
def
getIngestionPolicy
(
self
,
reference
,
ingestion_script
):
...
...
@@ -118,7 +119,9 @@ class TestDataIngestion(SecurityTestCase):
self
.
simulateIngestionAlarm
(
ingestion_id
,
now
)
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
):
...
...
@@ -135,28 +138,3 @@ class TestDataIngestion(SecurityTestCase):
data_stream
=
self
.
getDataStream
(
ingestion_reference
)
self
.
assertEqual
(
len
(
data_chunk
),
len
(
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 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W:13
4
, 4: Unused variable \'ingestion_id\' (unused-variable)
</string>
<string>
W:1
27
, 16: Unused variable \'nparray\' (unused-variable)
</string>
<string>
W:13
7
, 4: Unused variable \'ingestion_id\' (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>
</tuple>
</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