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
c1aee961
Commit
c1aee961
authored
Oct 28, 2020
by
Manuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
traceRetrieval: added pizza testcase
parent
25546930
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
147 additions
and
38 deletions
+147
-38
add_pizza_table.py
...app/_add_use_case_scripts/debug/tables/add_pizza_table.py
+76
-10
test_insert_pizza.py
src/rest-gateway/app/tests/test_insert_pizza.py
+44
-0
MessageHandler.py
...ce-retrieval-microservice/app/messaging/MessageHandler.py
+2
-2
test_by.py
...-hub-in/trace-retrieval-microservice/app/tests/test_by.py
+25
-26
No files found.
src/participation-hub/business-logic-microservice/app/_add_use_case_scripts/debug/tables/add_pizza_table.py
View file @
c1aee961
import
network_constants
as
nc
from
security.token_manager
import
TokenManager
from
typing
import
Dict
,
List
import
requests
def
add_
table
(
use_case
:
str
,
table_name
:
str
):
def
add_
layers
(
use_case
:
str
,
table_name
:
str
,
layers
:
List
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
columns
=
{
"name"
:
"name"
,
"dough"
:
"dough//type"
,
"cheese"
:
"dough//cheese"
,
"sauce"
:
"sauces[0]//name"
,
"sugar"
:
"sauces[0]//sugarcontent"
,
"UniqueID"
:
"name+dough//type"
}
for
layer
in
layers
:
url
=
f
"https://articonf1.itec.aau.at:30420/api/layers"
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
layer
)
print
(
url
+
": "
+
str
(
response
.
status_code
)
+
" "
+
response
.
text
)
def
add_table
(
use_case
:
str
,
table_name
:
str
,
columns
:
Dict
):
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
url
=
f
"https://articonf1.itec.aau.at:30420/api/use-cases/{use_case}/tables"
...
...
@@ -34,4 +45,59 @@ def add_table(use_case: str, table_name: str):
def
main
(
use_case
:
str
):
print
(
"PIZZA"
)
add_table
(
use_case
,
"pizza"
)
\ No newline at end of file
# table 1
add_table
(
use_case
,
"order"
,
{
"UniqueID"
:
"orderId"
,
"pizzaId"
:
"pizza"
,
"totalPrice"
:
"price"
}
)
# table 2
add_table
(
use_case
,
"pizza"
,
{
"UniqueID"
:
"id"
,
"name"
:
"name"
,
"doughType"
:
"dough//type"
,
"hasSpinach"
:
"dough//spinach"
,
"firstTopping"
:
"toppings[0]//name"
,
"firstToppingPrice"
:
"toppings[0]//price"
,
"toppingInfo"
:
"toppings[0]//name+toppings[0]//price"
}
)
# layers table 1
add_layers
(
use_case
,
"pizza"
,
[
{
"use_case"
:
use_case
,
"table"
:
"pizza"
,
"name"
:
"Price_Layer"
,
"properties"
:
[
"UniqueID"
,
"firstToppingPrice"
],
"cluster_properties"
:
[
"firstToppingPrice"
]
},
{
"use_case"
:
use_case
,
"table"
:
"pizza"
,
"name"
:
"Dough_Layer"
,
"properties"
:
[
"UniqueID"
,
"doughType"
],
"cluster_properties"
:
[
"doughType"
]
},
]
)
\ No newline at end of file
src/rest-gateway/app/tests/test_insert_pizza.py
0 → 100644
View file @
c1aee961
import
unittest
import
manage_sys_paths
from
messaging.DummyMessageManager
import
DummyMessageManager
# init dummy message manager so no connection to rabbitmq is established
_
=
DummyMessageManager
.
get_instance
()
import
routes.blockchain_trace
as
blockchain_trace
from
env_info
import
get_resources_path
from
security.token_manager
import
TokenManager
import
network_constants
import
json
import
requests
class
Test_BlockchainTrace
(
unittest
.
TestCase
):
def
test_isBlockchainTraceValid_validInputAndTypes
(
self
):
with
open
(
f
"{get_resources_path()}/pizza_transactions.json"
)
as
f
:
transactions
=
json
.
loads
(
f
.
read
())
jwt
=
TokenManager
.
getInstance
()
.
getToken
()
for
transaction
in
transactions
:
url
=
f
'https://{network_constants.REST_GATEWAY_HOSTNAME}:{network_constants.REST_GATEWAY_REST_PORT}/api/trace'
response
=
requests
.
post
(
url
,
verify
=
False
,
proxies
=
{
"http"
:
None
,
"https"
:
None
},
headers
=
{
"Authorization"
:
f
"Bearer {jwt}"
},
json
=
transaction
)
print
(
f
"{url} {response.status_code}"
)
if
response
.
status_code
!=
201
:
print
(
f
"server responded with {response.status_code}: {response.text}"
)
self
.
assertTrue
(
response
.
status_code
==
201
,
"Should accept the new trace."
)
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
src/transaction-hub-in/trace-retrieval-microservice/app/messaging/MessageHandler.py
View file @
c1aee961
...
...
@@ -91,8 +91,8 @@ class MessageHandler:
mappings - Required: contains string->path mappings, describing how the flattened object is built
'''
print
(
"TRANSACTION: "
+
str
(
transaction
))
print
(
"MAPPINGS: "
+
str
(
mappings
))
#
print("TRANSACTION: "+str(transaction))
#
print("MAPPINGS: "+str(mappings))
flattened
=
{}
...
...
src/transaction-hub-in/trace-retrieval-microservice/app/tests/test_by.py
View file @
c1aee961
...
...
@@ -67,8 +67,8 @@ class Test_MessageHandler(unittest.TestCase):
def
_get_pizza_message
(
self
)
->
str
:
message_values
=
\
{
'type'
:
'blockchain-transaction'
,
'content'
:
"type"
:
"blockchain-transaction"
,
"content"
:
{
"ApplicationType"
:
"debug"
,
"docType"
:
"pizza"
,
...
...
@@ -92,7 +92,6 @@ class Test_MessageHandler(unittest.TestCase):
"price"
:
0.1
,
}
],
}
}
return
json
.
dumps
(
message_values
)
...
...
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