Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jochem Bijlard
fractalis
Commits
75b10cfc
Commit
75b10cfc
authored
May 23, 2018
by
Jochem Bijlard
Browse files
Fixes for tests
parent
e1ce3f1b
Pipeline
#5257
failed with stages
in 27 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
tests/unit/etls/transmart/test_etl_categorical.py
View file @
75b10cfc
...
...
@@ -12,6 +12,10 @@ from fractalis.data.etls.transmart.etl_categorical import CategoricalETL
class
TestCategoricalETL
:
etl
=
CategoricalETL
()
descriptor
=
dict
(
constraint
=
''
,
data_type
=
'categorical'
)
def
test_correct_handler
(
self
):
assert
self
.
etl
.
can_handle
(
handler
=
'transmart'
,
...
...
@@ -31,7 +35,7 @@ class TestCategoricalETL:
content_type
=
'application/json'
)
with
pytest
.
raises
(
ValueError
)
as
e
:
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
'[400]'
in
e
def
test_extract_raises_readable_if_not_json
(
self
):
...
...
@@ -42,7 +46,7 @@ class TestCategoricalETL:
content_type
=
'application/json'
)
with
pytest
.
raises
(
ValueError
)
as
e
:
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
'unexpected data'
in
e
def
test_extract_works_for_valid_input
(
self
):
...
...
@@ -52,12 +56,12 @@ class TestCategoricalETL:
status
=
200
,
content_type
=
'application/json'
)
raw_data
=
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
isinstance
(
raw_data
,
dict
)
def
test_transform_valid_input_correct_output
(
self
):
body
=
{
"cells"
:
[{
"inlineDimensions"
:
[
"292278994-08-16T23:00:00Z"
,
None
,
"@"
],
"dimensionIndexes"
:
[
0
,
0
,
0
,
None
,
0
,
None
,
None
],
"
numeric
Value"
:
52.0
}],
# noqa: 501
"cells"
:
[{
"inlineDimensions"
:
[
"292278994-08-16T23:00:00Z"
,
None
,
"@"
],
"dimensionIndexes"
:
[
0
,
0
,
0
,
None
,
0
,
None
,
None
],
"
string
Value"
:
'FOO'
}],
# noqa: 501
"dimensionElements"
:
{
"patient"
:
[{
"id"
:
1000421548
,
"deathDate"
:
None
,
"birthDate"
:
None
,
"race"
:
None
,
"maritalStatus"
:
None
,
"inTrialId"
:
"3052"
,
"age"
:
52
,
"trial"
:
"GSE4382"
,
"sexCd"
:
None
,
"sex"
:
"unknown"
,
"religion"
:
None
}]}
# noqa: E501
}
with
responses
.
RequestsMock
()
as
response
:
...
...
@@ -66,8 +70,8 @@ class TestCategoricalETL:
status
=
200
,
content_type
=
'application/json'
)
raw_data
=
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
df
=
self
.
etl
.
transform
(
raw_data
=
raw_data
,
descriptor
=
{
'path'
:
''
}
)
assert
df
.
shape
==
(
1
,
2
)
assert
df
.
values
.
tolist
()
==
[[
'3052'
,
52.0
]]
assert
list
(
df
)
==
[
'id'
,
'value'
]
token
=
''
,
descriptor
=
self
.
descriptor
)
df
=
self
.
etl
.
transform
(
raw_data
=
raw_data
,
descriptor
=
self
.
descriptor
)
assert
df
.
shape
==
(
1
,
3
)
assert
df
.
values
.
tolist
()
==
[[
'3052'
,
'value'
,
'FOO'
]]
assert
list
(
df
)
==
[
'id'
,
'feature'
,
'value'
]
tests/unit/etls/transmart/test_etl_highdim.py
View file @
75b10cfc
...
...
@@ -16,9 +16,9 @@ class TestHighdimlETL:
def
test_correct_handler
(
self
):
assert
self
.
etl
.
can_handle
(
handler
=
'transmart'
,
descriptor
=
{
'data_type'
:
'
highdim
'
})
descriptor
=
{
'data_type'
:
'
numerical_array
'
})
assert
not
self
.
etl
.
can_handle
(
handler
=
'ada'
,
descriptor
=
{
'data_type'
:
'
highdim
'
})
descriptor
=
{
'data_type'
:
'
numerical_array
'
})
assert
not
self
.
etl
.
can_handle
(
handler
=
'ada'
,
descriptor
=
{
'data_type'
:
'categorical'
})
assert
not
self
.
etl
.
can_handle
(
handler
=
'ada'
,
...
...
tests/unit/etls/transmart/test_etl_numerical.py
View file @
75b10cfc
...
...
@@ -12,6 +12,10 @@ from fractalis.data.etls.transmart.etl_numerical import NumericalETL
class
TestNumericalETL
:
etl
=
NumericalETL
()
descriptor
=
dict
(
constraint
=
''
,
data_type
=
'numerical'
)
def
test_correct_handler
(
self
):
assert
self
.
etl
.
can_handle
(
handler
=
'transmart'
,
...
...
@@ -31,7 +35,7 @@ class TestNumericalETL:
content_type
=
'application/json'
)
with
pytest
.
raises
(
ValueError
)
as
e
:
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
'[400]'
in
e
def
test_extract_raises_readable_if_not_json
(
self
):
...
...
@@ -42,7 +46,7 @@ class TestNumericalETL:
content_type
=
'application/json'
)
with
pytest
.
raises
(
ValueError
)
as
e
:
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
'unexpected data'
in
e
def
test_extract_works_for_valid_input
(
self
):
...
...
@@ -52,7 +56,7 @@ class TestNumericalETL:
status
=
200
,
content_type
=
'application/json'
)
raw_data
=
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
token
=
''
,
descriptor
=
self
.
descriptor
)
assert
isinstance
(
raw_data
,
dict
)
def
test_transform_valid_input_correct_output
(
self
):
...
...
@@ -65,9 +69,10 @@ class TestNumericalETL:
body
=
json
.
dumps
(
body
),
status
=
200
,
content_type
=
'application/json'
)
raw_data
=
self
.
etl
.
extract
(
server
=
'http://foo.bar'
,
token
=
''
,
descriptor
=
{
'path'
:
''
}
)
df
=
self
.
etl
.
transform
(
raw_data
=
raw_data
,
descriptor
=
{
'path'
:
''
}
)
assert
df
.
shape
==
(
1
,
2
)
assert
df
.
values
.
tolist
()
==
[[
'3052'
,
52.0
]]
assert
list
(
df
)
==
[
'id'
,
'value'
]
token
=
''
,
descriptor
=
self
.
descriptor
)
df
=
self
.
etl
.
transform
(
raw_data
=
raw_data
,
descriptor
=
self
.
descriptor
)
assert
df
.
shape
==
(
1
,
3
)
assert
df
.
values
.
tolist
()
==
[[
'3052'
,
'value'
,
52.0
]]
assert
list
(
df
)
==
[
'id'
,
'feature'
,
'value'
]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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