Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
f6af0a8e
Commit
f6af0a8e
authored
Mar 01, 2021
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Test Code
parent
4c4c978a
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
555 additions
and
573 deletions
+555
-573
test_coverage.py
...ub/role-stage-discovery-microservice/app/test_coverage.py
+3
-1
test_cluster.py
...le-stage-discovery-microservice/app/tests/test_cluster.py
+18
-24
test_cluster_result.py
...e-discovery-microservice/app/tests/test_cluster_result.py
+84
-105
test_clusterer.py
...-stage-discovery-microservice/app/tests/test_clusterer.py
+143
-145
test_similarity.py
...stage-discovery-microservice/app/tests/test_similarity.py
+286
-290
test_coverage.py
...ta-hub/semantic-linking-microservice/app/test_coverage.py
+3
-1
test_pipeline.py
.../semantic-linking-microservice/app/tests/test_pipeline.py
+2
-2
test_coverage.py
...tion-hub/business-logic-microservice/app/test_coverage.py
+3
-1
test_layer_adapter.py
...siness-logic-microservice/app/tests/test_layer_adapter.py
+1
-1
test_coverage.py
src/rest-gateway/app/test_coverage.py
+5
-0
test_coverage.py
...-hub-in/trace-retrieval-microservice/app/test_coverage.py
+4
-0
test_MessageHandler.py
...e-retrieval-microservice/app/tests/test_MessageHandler.py
+3
-3
No files found.
src/data-hub/role-stage-discovery-microservice/app/test_coverage.py
View file @
f6af0a8e
...
@@ -3,7 +3,9 @@ import sys
...
@@ -3,7 +3,9 @@ import sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
#####################################
### Don't include for test report ###
#####################################
try
:
try
:
class
TestCoverage
(
unittest
.
TestCase
):
class
TestCoverage
(
unittest
.
TestCase
):
def
test_init_main
(
self
):
def
test_init_main
(
self
):
...
...
src/data-hub/role-stage-discovery-microservice/app/tests/test_cluster.py
View file @
f6af0a8e
try
:
import
unittest
import
sys
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
# python -m unittest discover
import
unittest
from
db.entities
import
Cluster
import
sys
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
from
datetime
import
date
,
datetime
# python -m unittest discover
import
json
from
db.entities
import
Cluster
from
datetime
import
date
,
datetime
import
json
class
TestCluster
(
unittest
.
TestCase
):
def
test_init_Cluster
(
self
):
try
:
c
=
Cluster
(
'debug'
,
'debug-table1'
,
'layer1'
,
1
,
[
1
,
2
,
3
])
self
.
assertEqual
(
'debug'
,
c
.
use_case
)
class
TestCluster
(
unittest
.
TestCase
):
self
.
assertEqual
(
'debug-table1'
,
c
.
use_case_table
)
def
test_init_Cluster
(
self
):
self
.
assertEqual
(
1
,
c
.
cluster_label
)
c
=
Cluster
(
'debug'
,
'debug-table1'
,
'layer1'
,
1
,
[
1
,
2
,
3
])
self
.
assertEqual
([
1
,
2
,
3
],
c
.
nodes
)
except
Exception
as
e
:
print
(
e
)
if
__name__
==
'__main__'
:
self
.
assertEqual
(
'debug'
,
c
.
use_case
)
unittest
.
main
()
self
.
assertEqual
(
'debug-table1'
,
c
.
use_case_table
)
except
Exception
as
e
:
self
.
assertEqual
(
1
,
c
.
cluster_label
)
print
(
"Exception found:"
)
self
.
assertEqual
([
1
,
2
,
3
],
c
.
nodes
)
print
(
e
)
if
__name__
==
'__main__'
:
unittest
.
main
()
src/data-hub/role-stage-discovery-microservice/app/tests/test_cluster_result.py
View file @
f6af0a8e
try
:
import
unittest
import
unittest
import
sys
import
sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
# python -m unittest discover
# python -m unittest discover
from
processing.clustering
import
ClusterResultConverter
,
ClusterResult
from
processing.clustering
import
ClusterResultConverter
,
ClusterResult
from
typing
import
List
,
Dict
,
Any
from
typing
import
List
,
Dict
,
Any
class
TestClusterResult
(
unittest
.
TestCase
):
class
TestClusterResult
(
unittest
.
TestCase
):
converter
:
ClusterResultConverter
=
None
converter
:
ClusterResultConverter
=
None
def
setUp
(
self
):
def
setUp
(
self
):
try
:
self
.
converter
=
ClusterResultConverter
()
self
.
converter
=
ClusterResultConverter
()
except
Exception
as
e
:
print
(
e
)
def
test_result_undefined_feature
(
self
):
cluster_groups
=
self
.
_get_some_cluster_groups_1d
()
def
test_result_undefined_feature
(
self
):
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
try
:
cluster_groups
=
cluster_groups
,
cluster_groups
=
self
.
_get_some_cluster_groups_1d
()
features
=
[]
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
)
cluster_groups
=
cluster_groups
,
features
=
[]
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
)
self
.
assert_correct_cluster_result_labels
([
'n.a.'
,
'n.a.'
,
'n.a.'
],
cluster_res
)
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
def
test_result_1d_feature
(
self
):
self
.
assert_correct_cluster_result_labels
([
'n.a.'
,
'n.a.'
,
'n.a.'
],
cluster_res
)
cluster_groups
=
self
.
_get_some_cluster_groups_1d
()
except
Exception
as
e
:
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
print
(
e
)
cluster_groups
=
cluster_groups
,
features
=
[
'v'
]
def
test_result_1d_feature
(
self
):
)
try
:
cluster_groups
=
self
.
_get_some_cluster_groups_1d
()
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
cluster_groups
=
cluster_groups
,
features
=
[
'v'
]
)
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
self
.
assert_correct_cluster_result_labels
([
'-1.0 -- 1.0'
,
'10.0 -- 11.0'
,
'2.0 -- 2.0'
],
cluster_res
)
except
Exception
as
e
:
print
(
e
)
def
test_result_2d_features
(
self
):
try
:
cluster_groups
=
self
.
_get_some_cluster_groups_2d
()
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
cluster_groups
=
cluster_groups
,
features
=
[
'v'
,
'u'
]
)
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
self
.
assert_correct_cluster_result_labels
([
str
((
0.0
,
0.0
)),
str
((
10.5
,
10.5
)),
str
((
2.0
,
2.0
)),
str
((
3.0
,
6.0
))],
cluster_res
)
except
Exception
as
e
:
print
(
e
)
#region Custom Assertions
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
self
.
assert_correct_cluster_result_labels
([
'-1.0 -- 1.0'
,
'10.0 -- 11.0'
,
'2.0 -- 2.0'
],
cluster_res
)
def
assert_correct_cluster_result_len
(
self
,
expected
:
'original dict of lists'
,
actual
:
Dict
[
Any
,
ClusterResult
]):
try
:
def
test_result_2d_features
(
self
):
self
.
assertEqual
(
len
(
expected
),
len
(
actual
))
for
i
in
range
(
len
(
expected
)):
cluster_groups
=
self
.
_get_some_cluster_groups_2d
()
self
.
assertEqual
(
len
(
expected
[
i
]),
len
(
actual
[
i
]
.
nodes
))
cluster_res
=
self
.
converter
.
convert_to_cluster_results
(
self
.
assertEqual
(
expected
[
i
],
actual
[
i
]
.
nodes
)
cluster_groups
=
cluster_groups
,
features
=
[
'v'
,
'u'
]
except
Exception
as
e
:
)
print
(
e
)
self
.
assert_correct_cluster_result_len
(
cluster_groups
,
cluster_res
)
def
assert_correct_cluster_result_labels
(
self
,
expected
:
List
[
str
],
actual
:
Dict
[
Any
,
ClusterResult
]):
self
.
assert_correct_cluster_result_labels
([
str
((
0.0
,
0.0
)),
str
((
10.5
,
10.5
)),
str
((
2.0
,
2.0
)),
str
((
3.0
,
6.0
))],
cluster_res
)
try
:
self
.
assertEqual
(
len
(
expected
),
len
(
actual
))
for
i
in
range
(
len
(
expected
)):
self
.
assertEqual
(
expected
[
i
],
actual
[
i
]
.
label
)
#region Custom Assertions
except
Exception
as
e
:
print
(
e
)
def
assert_correct_cluster_result_len
(
self
,
expected
:
'original dict of lists'
,
actual
:
Dict
[
Any
,
ClusterResult
]):
self
.
assertEqual
(
len
(
expected
),
len
(
actual
))
#endregion Custom Assertions
for
i
in
range
(
len
(
expected
)):
self
.
assertEqual
(
len
(
expected
[
i
]),
len
(
actual
[
i
]
.
nodes
))
#region helper methods
self
.
assertEqual
(
expected
[
i
],
actual
[
i
]
.
nodes
)
def
_get_some_cluster_groups_1d
(
self
):
return
{
0
:
[{
'v'
:
'0'
},
{
'v'
:
'1'
},
{
'v'
:
'-1'
}],
def
assert_correct_cluster_result_labels
(
self
,
expected
:
List
[
str
],
actual
:
Dict
[
Any
,
ClusterResult
]):
1
:
[{
'v'
:
'10'
},
{
'v'
:
'11'
}],
self
.
assertEqual
(
len
(
expected
),
len
(
actual
))
2
:
[{
'v'
:
'2'
}],
for
i
in
range
(
len
(
expected
)):
}
self
.
assertEqual
(
expected
[
i
],
actual
[
i
]
.
label
)
def
_get_some_cluster_groups_2d
(
self
):
#endregion Custom Assertions
return
{
0
:
[{
'v'
:
'0'
,
'u'
:
'0'
},
{
'v'
:
'1'
,
'u'
:
'1'
},
{
'v'
:
'-1'
,
'u'
:
'-1'
}],
#region helper methods
1
:
[{
'v'
:
'10'
,
'u'
:
'10'
},
{
'v'
:
'11'
,
'u'
:
'11'
}],
def
_get_some_cluster_groups_1d
(
self
):
2
:
[{
'v'
:
'2'
,
'u'
:
'2'
}],
return
{
3
:
[{
'v'
:
'7'
,
'u'
:
'7'
},
{
'v'
:
'5'
,
'u'
:
'3'
},
{
'v'
:
'-3'
,
'u'
:
'8'
}],
0
:
[{
'v'
:
'0'
},
{
'v'
:
'1'
},
{
'v'
:
'-1'
}],
}
1
:
[{
'v'
:
'10'
},
{
'v'
:
'11'
}],
#endregion helper methods
2
:
[{
'v'
:
'2'
}],
}
if
__name__
==
'__main__'
:
unittest
.
main
()
def
_get_some_cluster_groups_2d
(
self
):
except
Exception
as
e
:
return
{
print
(
"Exception found:"
)
0
:
[{
'v'
:
'0'
,
'u'
:
'0'
},
{
'v'
:
'1'
,
'u'
:
'1'
},
{
'v'
:
'-1'
,
'u'
:
'-1'
}],
print
(
e
)
1
:
[{
'v'
:
'10'
,
'u'
:
'10'
},
{
'v'
:
'11'
,
'u'
:
'11'
}],
\ No newline at end of file
2
:
[{
'v'
:
'2'
,
'u'
:
'2'
}],
3
:
[{
'v'
:
'7'
,
'u'
:
'7'
},
{
'v'
:
'5'
,
'u'
:
'3'
},
{
'v'
:
'-3'
,
'u'
:
'8'
}],
}
#endregion helper methods
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
src/data-hub/role-stage-discovery-microservice/app/tests/test_clusterer.py
View file @
f6af0a8e
This diff is collapsed.
Click to expand it.
src/data-hub/role-stage-discovery-microservice/app/tests/test_similarity.py
View file @
f6af0a8e
This diff is collapsed.
Click to expand it.
src/data-hub/semantic-linking-microservice/app/test_coverage.py
View file @
f6af0a8e
...
@@ -3,7 +3,9 @@ import sys
...
@@ -3,7 +3,9 @@ import sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
#####################################
### Don't include for test report ###
#####################################
try
:
try
:
class
TestCoverage
(
unittest
.
TestCase
):
class
TestCoverage
(
unittest
.
TestCase
):
def
test_init_main
(
self
):
def
test_init_main
(
self
):
...
...
src/data-hub/semantic-linking-microservice/app/tests/test_pipeline.py
View file @
f6af0a8e
...
@@ -67,8 +67,8 @@ class Test_Pipeline(unittest.TestCase):
...
@@ -67,8 +67,8 @@ class Test_Pipeline(unittest.TestCase):
}
}
}
}
}
}
#original name testTraceProcessing
def
test
TraceProcessing
(
self
):
def
test
_handle_new_trace_newTraceMsg_correctlyInserted
(
self
):
msg
=
self
.
_buildTraceMessage
()
msg
=
self
.
_buildTraceMessage
()
self
.
handler
.
handle_new_trace
(
msg
[
"content"
])
self
.
handler
.
handle_new_trace
(
msg
[
"content"
])
self
.
assertEqual
(
len
(
self
.
handler
.
_repository
.
layernodes
),
1
)
self
.
assertEqual
(
len
(
self
.
handler
.
_repository
.
layernodes
),
1
)
...
...
src/participation-hub/business-logic-microservice/app/test_coverage.py
View file @
f6af0a8e
...
@@ -3,7 +3,9 @@ import sys
...
@@ -3,7 +3,9 @@ import sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
#####################################
### Don't include for test report ###
#####################################
try
:
try
:
class
TestCoverage
(
unittest
.
TestCase
):
class
TestCoverage
(
unittest
.
TestCase
):
def
test_init_main
(
self
):
def
test_init_main
(
self
):
...
...
src/participation-hub/business-logic-microservice/app/tests/test_layer_adapter.py
View file @
f6af0a8e
...
@@ -4,7 +4,7 @@ from db.entities.layer_adapter import LayerAdapter
...
@@ -4,7 +4,7 @@ from db.entities.layer_adapter import LayerAdapter
class
Test_Layer_Adapter
(
unittest
.
TestCase
):
class
Test_Layer_Adapter
(
unittest
.
TestCase
):
def
test_
valid_adapter
(
self
):
def
test_
LayerAdapter_newLayerAdapterObj_validInstantiation
(
self
):
adapter1
=
LayerAdapter
(
"layer1"
,
"use_case"
,
"table"
,
[
"a"
,
"c"
],
[
"a"
])
adapter1
=
LayerAdapter
(
"layer1"
,
"use_case"
,
"table"
,
[
"a"
,
"c"
],
[
"a"
])
print
(
adapter1
.
to_serializable_dict
)
print
(
adapter1
.
to_serializable_dict
)
...
...
src/rest-gateway/app/test_coverage.py
View file @
f6af0a8e
...
@@ -2,6 +2,11 @@ import unittest
...
@@ -2,6 +2,11 @@ import unittest
import
sys
import
sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
#####################################
### Don't include for test report ###
#####################################
try
:
try
:
class
TestCoverage
(
unittest
.
TestCase
):
class
TestCoverage
(
unittest
.
TestCase
):
def
test_init_main
(
self
):
def
test_init_main
(
self
):
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/test_coverage.py
View file @
f6af0a8e
...
@@ -3,6 +3,10 @@ import sys
...
@@ -3,6 +3,10 @@ import sys
for
path
in
[
'../'
,
'./'
]:
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
sys
.
path
.
insert
(
1
,
path
)
#####################################
### Don't include for test report ###
#####################################
try
:
try
:
class
TestCoverage
(
unittest
.
TestCase
):
class
TestCoverage
(
unittest
.
TestCase
):
def
test_init_main
(
self
):
def
test_init_main
(
self
):
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/tests/test_MessageHandler.py
View file @
f6af0a8e
...
@@ -170,7 +170,7 @@ class Test_MessageHandler(unittest.TestCase):
...
@@ -170,7 +170,7 @@ class Test_MessageHandler(unittest.TestCase):
self
.
assertEqual
(
'semantic-linking'
,
self
.
msg_sender
.
last_message
[
'key'
])
self
.
assertEqual
(
'semantic-linking'
,
self
.
msg_sender
.
last_message
[
'key'
])
self
.
assertEqual
(
'new-trace'
,
json
.
loads
(
self
.
msg_sender
.
last_message
[
'msg'
])[
"type"
])
self
.
assertEqual
(
'new-trace'
,
json
.
loads
(
self
.
msg_sender
.
last_message
[
'msg'
])[
"type"
])
def
test_handle
blockchain_duplicateTrace
(
self
):
def
test_handle
BlockchainTransaction_duplicateTrace_oneTransAddedToDuplicateRepo
(
self
):
msg
=
self
.
_get_valid_message
()
msg
=
self
.
_get_valid_message
()
msg2
=
self
.
_get_valid_message
()
msg2
=
self
.
_get_valid_message
()
msg
=
eval
(
msg
)
msg
=
eval
(
msg
)
...
@@ -179,7 +179,7 @@ class Test_MessageHandler(unittest.TestCase):
...
@@ -179,7 +179,7 @@ class Test_MessageHandler(unittest.TestCase):
self
.
handler
.
handle_blockchain_transaction
(
msg2
[
'content'
])
self
.
handler
.
handle_blockchain_transaction
(
msg2
[
'content'
])
self
.
assertEqual
(
len
(
self
.
repo
.
added_transactions
),
len
(
self
.
repo
.
duplicated_transactions
))
self
.
assertEqual
(
len
(
self
.
repo
.
added_transactions
),
len
(
self
.
repo
.
duplicated_transactions
))
def
test_handle
blockchain_duplicateTraceDifferentTabl
e
(
self
):
def
test_handle
BlockchainTransaction_duplicateTraceDifferentTable_bothTransactionsAddedAsUniqu
e
(
self
):
msg
=
self
.
_get_valid_message
()
msg
=
self
.
_get_valid_message
()
msg2
=
self
.
_get_valid_message2
()
msg2
=
self
.
_get_valid_message2
()
msg
=
eval
(
msg
)
msg
=
eval
(
msg
)
...
@@ -188,7 +188,7 @@ class Test_MessageHandler(unittest.TestCase):
...
@@ -188,7 +188,7 @@ class Test_MessageHandler(unittest.TestCase):
self
.
handler
.
handle_blockchain_transaction
(
msg2
[
'content'
])
self
.
handler
.
handle_blockchain_transaction
(
msg2
[
'content'
])
self
.
assertEqual
(
len
(
self
.
repo
.
added_transactions
),
2
)
self
.
assertEqual
(
len
(
self
.
repo
.
added_transactions
),
2
)
def
test_handle
blockchain_duplicateTraceDifferentUseCas
e
(
self
):
def
test_handle
BlockchainTransaction_duplicateTraceDifferentUseCase_bothTransactionsAddedAsUniqu
e
(
self
):
msg
=
self
.
_get_valid_message
()
msg
=
self
.
_get_valid_message
()
msg2
=
self
.
_get_valid_message3
()
msg2
=
self
.
_get_valid_message3
()
msg
=
eval
(
msg
)
msg
=
eval
(
msg
)
...
...
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