Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
wendelin
Commits
4adc8720
Commit
4adc8720
authored
Jul 16, 2020
by
Eteri
Committed by
Eteri
Jul 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin: test unpacking mgspack data and extracting dates
parent
eee332f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
12 deletions
+26
-12
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+26
-12
No files found.
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
4adc8720
...
...
@@ -349,10 +349,11 @@ class Test(ERP5TypeTestCase):
Test ingestion using a POST Request containing a msgpack encoded message
simulating input from fluentd.
"""
from
DateTime
import
DateTime
from
datetime
import
datetime
,
timedelta
import
time
portal
=
self
.
portal
now
=
DateTime
()
now
=
datetime
.
now
()
reference
=
"test_sensor.test_product"
title
=
reference
...
...
@@ -378,7 +379,7 @@ class Test(ERP5TypeTestCase):
'reference'
:
reference
.
split
(
'.'
)[
0
],
'version'
:
'001'
,
'effective_date'
:
now
,
'expiration_date'
:
now
+
365
*
10
}
'expiration_date'
:
now
+
timedelta
(
days
=
365
)
}
data_supply
=
portal
.
data_supply_module
.
newContent
(
\
portal_type
=
'Data Supply'
,
**
data_supply_kw
)
data_supply
.
validate
()
...
...
@@ -403,18 +404,19 @@ class Test(ERP5TypeTestCase):
self
.
tic
()
portal
.
log
(
"data_supply = "
,
data_supply
)
portal
.
log
(
"ingestion_policy = "
,
ingestion_policy
)
data_list
=
[]
int_date
=
int
(
time
.
mktime
(
now
.
timetuple
()))
real_data
=
[]
number_string_list
=
[]
for
my_list
in
list
(
chunks
(
range
(
0
,
100001
),
10
)
):
number_string_list
.
append
(
','
.
join
([
str
(
x
)
for
x
in
my_list
]))
real_data
=
'
\
n
'
.
join
(
number_string_list
)
# make sure real_data tail is also a full line
real_data
+=
'
\
n
'
# create data for ingestion in [date, value] format
for
x
in
range
(
0
,
10001
):
data_list
=
[]
data_list
=
[
int_date
,
x
]
real_data
.
append
(
data_list
)
int_date
=
int_date
+
1000
# simulate fluentd
body
=
msgpack
.
packb
(
[
0
,
real_data
]
,
use_bin_type
=
True
)
body
=
msgpack
.
packb
(
real_data
,
use_bin_type
=
True
)
env
=
{
'CONTENT_TYPE'
:
'application/octet-stream'
}
path
=
ingestion_policy
.
getPath
()
+
'/ingest?reference='
+
reference
...
...
@@ -438,6 +440,18 @@ class Test(ERP5TypeTestCase):
# body is msgpacked real data.
self
.
assertEqual
(
body
,
data_stream_data
)
# unpack data
start
=
0
end
=
len
(
data_stream_data
)
unpacked
,
end
=
data_stream
.
readMsgpackChunkList
(
start
,
end
)
# compare unpacked data with real data
self
.
assertEqual
([
real_data
],
unpacked
)
# extract dates and compare with real dates
f
=
data_stream
.
extractDateTime
for
i
in
range
(
0
,
len
(
unpacked
[
0
])):
self
.
assertEqual
(
np
.
datetime64
(
real_data
[
i
][
0
],
's'
),
f
(
unpacked
[
0
][
i
][
0
]))
# clean up
data_stream
.
setData
(
None
)
self
.
tic
()
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