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
4e2e062c
Commit
4e2e062c
authored
Nov 05, 2020
by
Bogdan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Semantic Linking unit test update
parent
978d11f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
2 deletions
+76
-2
MessageHandler.py
...ntic-linking-microservice/app/messaging/MessageHandler.py
+2
-2
test_pipeline.py
.../semantic-linking-microservice/app/tests/test_pipeline.py
+74
-0
No files found.
src/data-hub/semantic-linking-microservice/app/messaging/MessageHandler.py
View file @
4e2e062c
...
...
@@ -96,7 +96,7 @@ class MessageHandler:
node
[
"table"
]
=
layer
.
table
node
[
"use_case"
]
=
layer
.
use_case
nodes
.
append
(
node
)
unique_id_list
.
append
(
node
[
"UniqueI
d
"
])
unique_id_list
.
append
(
node
[
"UniqueI
D
"
])
#check for duplicates
#TODO EDIT NODES_IN_DB RETURN
...
...
@@ -104,7 +104,7 @@ class MessageHandler:
# if len(nodes_in_db) > 0: #found duplicates
# #remove duplicates from nodes:
# for node in nodes:
# if node["UniqueI
d
"] in nodes_in_db:
# if node["UniqueI
D
"] in nodes_in_db:
# nodes.remove(node)
#no duplicates anymore
...
...
src/data-hub/semantic-linking-microservice/app/tests/test_pipeline.py
View file @
4e2e062c
...
...
@@ -8,9 +8,76 @@ from messaging.DummyMessageManager import DummyMessageManager as DummyMessageSen
class
DummyMongoRepo
:
'''Dummy class to be used for testing the MessageHandler'''
last_trace
=
None
DBnodes
=
[]
def
insert_trace
(
self
,
trace
):
self
.
last_trace
=
trace
def
get_layers_for_use_case_and_table
(
use_case
,
table
):
testLayers
=
[
{
"layer_name"
:
"layer1"
,
"properties"
:
[
"UniqueID"
,
"doughType"
],
"table"
:
"pizza"
,
"total_properties"
:
[
"UniqueID"
,
"doughType"
,
"firstTopping"
,
"firstToppingPrice"
,
"hasSpinach"
,
"name"
,
"toppingInfo"
],
"use_case"
:
"debug"
},
{
"layer_name"
:
"layer2"
,
"properties"
:
[
"firstTopping"
],
"table"
:
"pizza"
,
"total_properties"
:
[
"UniqueID"
,
"doughType"
,
"firstTopping"
,
"firstToppingPrice"
,
"hasSpinach"
,
"name"
,
"toppingInfo"
],
"use_case"
:
"debug"
}
]
returnLayers
=
[]
for
layer
in
testLayers
:
if
(
layer
[
"use_case"
]
==
use_case
)
and
(
layer
[
"table"
]
==
table
):
returnLayers
.
append
(
layer
)
return
returnLayers
# layers = self._repository.get_layers_for_use_case_and_table(use_case, table)
## if no local layers are found, fetch information from server
# if len(layers) == 0:
# layers = self._fetch_layer_information(use_case, table)
# self._repository.delete_layer(layer)
# self._repository.add_layer(layer)
#TODO
# nodes_in_db = self._repository.get_nodes_from_ids(unique_id_list)
#TODO first
# self._repository.add_layer_nodes(nodes)
def
add_layer_nodessss
(
nodes
):
DBnodes
.
extend
(
nodes
)
return
class
Test_Pipeline
(
unittest
.
TestCase
):
handler
=
None
repo
=
None
...
...
@@ -44,6 +111,13 @@ class Test_Pipeline(unittest.TestCase):
msg
=
self
.
_buildTraceMessage
()
self
.
handler
.
handle_new_trace
(
msg
[
"content"
])
def
testDuplicateTrace
(
self
):
msg
=
self
.
_buildTraceMessage
()
msg2
=
self
.
_buildTraceMessage
()
self
.
handler
.
handle_new_trace
(
msg
[
"content"
])
self
.
handler
.
handle_new_trace
(
msg2
[
"content"
])
self
.
assertEqual
(
len
(
self
.
repo
.
DBnodes
),
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
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