-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcombination_parser.py
71 lines (65 loc) · 1.97 KB
/
combination_parser.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
import json
class combination:
def __init__(self):
self.env = [
{
"type": "host",
"name": "host_1",
"ip": "127.0.0.1",
"password": "openEuler12#$",
"port": "22",
"user": "root",
}
]
self.combinations = [
{
"name": "mugen_test",
"testcases": [
]
}
]
self.execute = [
{
"env":["host_1"],
"combination":"mugen_test"
}
]
def add_case(self , testsuite , testcase):
flag = False
for suite in self.combinations[0]['testcases']:
if suite['testsuite'] == testsuite:
if testcase not in suite['add']:
suite['add'].append(testcase)
flag = True
break
if not flag:
self.combinations[0]['testcases'].append(
{
"testsuite":testsuite ,
"add":[testcase]
}
)
def export_json(self):
dicts = {
'env' : self.env ,
'combination' : self.combinations ,
'execute' : self.execute
}
with open('test.json' , 'w') as f:
f.write(json.dumps(dicts , indent=4))
def export_every_json(self):
for testsuite in self.combinations[0]['testcases']:
dicts = {
'env' : self.env ,
'combination' : [
{
"name": "mugen_test",
"testcases": [
testsuite
]
}
] ,
'execute' : self.execute
}
with open(testsuite['testsuite']+'_test.json' , 'w') as f:
f.write(json.dumps(dicts , indent=4))