forked from ProcessDryLab-master-project/Tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNegativeTests.py
153 lines (118 loc) · 5.29 KB
/
NegativeTests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from API import API
from TestCases import TestCases
import time
from uuid import UUID
import json
class Negative() :
logMetadataValid = {
'FileExtension': 'pnml',
'ResourceLabel': 'ML4_model',
'ResourceType': 'PetriNet',
'Description': 'ML4 Test Petri Net'
}
logMetadataInvalid = { # No ResourceType, Repository should not accept it.
'FileExtension': 'xes',
'ResourceLabel': 'ML4_log',
'Description': 'ML4 Test log'
}
streamMetadataValid = {
'Host': 'mqtt.eclipseprojects.io',
'StreamTopic': 'TestStream',
'ResourceLabel': 'Test Stream',
'ResourceType': 'EventStream',
'Description': 'Stream for testing',
'Overwrite': 'true'
}
streamMetadataInvalid = { # An EventStream without a topic should be blocked
'Host': 'mqtt.eclipseprojects.io',
'ResourceLabel': 'Test Stream',
'ResourceType': 'EventStream',
'Description': 'Stream for testing',
'Overwrite': 'true'
}
invalidFilters = [
"IN",
"VALID"
]
cloning_body = {
"Host": "http://localhost:5000/shadow/",
"Config": {
"MinerId": "3",
"MinerLabel": "Inductive Miner",
"Type": "Miner",
"MinerPath": "Miners/MinerInductiveBpmnPy",
"MinerFile": "MinerInductiveBpmn.py",
"Access": "Public",
"Shadow": False, # Shadow is false, so it should be rejected
"ResourceInput": [
{
"Name": "LogToRun",
"FileExtension": "xes",
"ResourceType": "EventLog"
}
],
"ResourceOutput": {
"FileExtension": "bpmn",
"ResourceType": "ProcessModel"
},
"MinerParameters": []
}
}
def negativeTestRun(self):
testCases = TestCases()
repoTestDict = dict()
minerTestDict = dict()
# ------------------------ REPOSITORY TEST RUNS --------------------------
# Upload file with invalid metadata
success, file_rid = testCases.testFileUpload('./Resources/ML4_log.xes', self.logMetadataInvalid)
repoTestDict["testFileUpload"] = not success
# Request metadata with invalid RID
success, error = testCases.testGetFileMDO("18752fc4-a019-4266-8ad7-ff1d6e47b7e4", self.logMetadataValid)
repoTestDict["testGetFileMDO"] = not success
# Request file with invalid RID
success = testCases.testGetFile("18752fc4-a019-4266-8ad7-ff1d6e47b7e4")
repoTestDict["testGetFile"] = not success
# Request graph with invalid RID
success = testCases.testGetGraph("18752fc4-a019-4266-8ad7-ff1d6e47b7e4")
repoTestDict["testGetGraph"] = not success
# Upload valid pnml file to use later
success, file_rid = testCases.testFileUpload('./Resources/ML4_model.pnml', self.logMetadataValid)
success, file_mdo = testCases.testGetFileMDO(file_rid, self.logMetadataValid)
print("valid file_mdo: " + str(file_mdo))
# repoTestDict["testFileUpload"] = success # Has to work for later tests to make sense
# Request histogram for the PNML, which should not be possible.
success = testCases.testGetHistogram(file_rid)
repoTestDict["testGetHistogram"] = not success
# Upload invalid metadata for a stream
success, mdo_rid = testCases.testUploadMetadata(self.streamMetadataInvalid)
repoTestDict["testUploadMetadata"] = not success
# Request metadata object with invalid RID
success = testCases.testGetStreamMDO("18752fc4-a019-4266-8ad7-ff1d6e47b7e4", self.streamMetadataValid)
repoTestDict["testGetStreamMDO"] = not success
# Request list of metadata objects with invalid filters
success = testCases.testFilteredMetadataList(self.invalidFilters)
repoTestDict["testFilteredMetadataList"] = not success
# ------------------------ MINER TEST RUNS --------------------------
# Test file consuming miner start with invalid metadata input (PNML instead of XES)
success, file_pid = testCases.testFileMinerStart(file_mdo)
minerTestDict["testFileMinerStart"] = not success
# Test that miner has no active processes with file_pid
success = testCases.testMinerStatusList(file_pid)
minerTestDict["testMinerStatusList"] = not success
# Try to stop a process that doesn't exist
success = testCases.testFileMinerStop("InvalidPid")
minerTestDict["testFileMinerStop"] = not success
# Test get miner algorithm file for unshadowable miner
success = testCases.testGetAlgorithmFile("2")
minerTestDict["testGetAlgorithmFile"] = not success
# Test get miner algorithm requirements unshadowable miner
success = testCases.testGetRequirementsFile("2")
minerTestDict["testGetRequirementsFile"] = not success
# Test run cloning action
success, cid = testCases.testCloneStart(self.cloning_body)
minerTestDict["testCloneStart"] = not success
# Test that there is no cloning status
success = testCases.testCloneStatus(cid)
minerTestDict["testCloneStatus"] = not success
return repoTestDict, minerTestDict
# Consider if we should do additional cleanup afterwards?