-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.py
223 lines (171 loc) · 5.31 KB
/
test.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# import logging
# import sys
from app import App
from script import Script
logfile = "log_pmneo4j.txt"
bolt_url = "bolt://localhost:7687"
user = "neo4j"
password = "neo4j"
def test():
# test_prop_check_exists() # passed
# test_update_prop() # passed
# test_update_prop_name() # passed
# test_conn_check_exists() # passed
# test_open_file() # passed
# test_script_prop() # passed
# test_script_conn() # passed
# test_script_name() # passed
# test_script_load_tactics() # passed
# test_script_use_tactics() # passed
# test_script_run() # passed
# test_script_run2() # passed
# test_script_chinese_comment() # passed
pass
####################
def test_prop_check_exists():
app = App(bolt_url, user, password)
app.clear_all()
app.create_pm_prop("1.01", "1", "1", "A", "94", "Df")
print("Check prop exists")
print(app.check_prop_exists("1.01"))
app.close()
def test_update_prop():
app = App(bolt_url, user, password)
app.clear_all()
app.create_pm_prop("1.01", "1", "1", "A", "94", "Df")
print("Check prop exists")
print(app.check_prop_exists("1.01"))
print("Updating prop for test...")
app.create_pm_prop("1.01", "1", "1", "A", "94", "Thm")
app.close()
def test_update_prop_name():
app = App(bolt_url, user, password)
app.clear_all()
app.create_pm_prop("1.01", "1", "1", "A", "94", "Df")
print("Updating prop name...")
app.update_prop_name("1.01", "test")
app.close()
def test_conn_check_exists():
app = App(bolt_url, user, password)
app.clear_all()
app.create_pm_prop("1.01", "1", "1", "A", "94", "Df")
app.create_pm_prop("2.02", "1", "1", "A", "94", "Df")
app.connect_pm("1.01", "2.02")
print(app.check_conn_exists("1.01", "2.02"))
app.close()
def test_template():
app = App(bolt_url, user, password)
app.clear_all()
# TODO: template
app.close()
####################################
def test_open_file():
file = open(logfile, 'r')
line = file.readline()
print("Successfully read log file, line 1: " + line)
file.close()
file = open("scripts/tactics.txt", 'r')
line = file.readline()
print("Successfully read tactics file, line 1: " + line)
file.close()
file = open("scripts/v1/pm.txt", 'r')
line = file.readline()
print("Successfully read pm file, line 1: " + line)
file.close()
return
def test_script_prop():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
lines = "volume 1\npart 1\nsection A\n\npage 94\nDf 1.01\nThm 1.1\nPp 2.2\n".split("\n")
i = 0
for l in lines:
print("Parsing line " + str(i) + "| " + l)
s.parse_line(l, i)
i += 1
if app.check_prop_exists("1.01"): print("1.01 exists")
if app.check_prop_exists("1.1"): print("1.1 exists")
if app.check_prop_exists("2.2"): print("2.2 exists")
s.close()
def test_script_conn():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
lines = "volume 1\npart 1\nsection A\n\npage 94\nPp 1.1\nThm 2.2\n<- 1.1".split("\n")
i = 0
for l in lines:
print("Parsing line " + str(i) + "| " + l)
s.parse_line(l, i)
i += 1
print("Checking if connection 1.1 -> 2.2 exists...")
print(app.check_conn_exists("1.1", "2.2"))
s.close()
def test_script_name():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
lines = "volume 1\npart 1\nsection A\n\npage 94\nPp 1.1\nname test".split("\n")
i = 0
for l in lines:
print("Parsing line " + str(i) + "| " + l)
s.parse_line(l, i)
i += 1
print("Name should be generated")
s.close()
def test_script_load_tactics():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
# TODO: read file, parse tactics
s.load_tactics()
for k in s.tactics:
print("Tactic {k}: {tt}".format(k=k, tt=s.tactics[k]))
s.close()
def test_script_use_tactics():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
print("Reading tactics.txt file...")
s.load_tactics()
for k in s.tactics:
print("Tactic {k}: {tt}".format(k=k, tt=s.tactics[k]))
print("Reading & parsing testtactics file...")
s.script = "scripts/testtactics.txt"
s.parse_file()
for k in s.tactics:
print("Tactic {k}: {tt}".format(k=k, tt=s.tactics[k]))
print("Saving tactics...")
s.save_tactics() # Examine the file...
s.close()
def test_script_run():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
s.script = "scripts/testtactics.txt"
print("Running full logic...")
s.run()
s.close()
def test_script_run2():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
s.script = "scripts/test/testtactics.txt"
print("Running full logic...")
s.run()
print("Running for twice...")
s.run()
s.close()
def test_script_chinese_comment():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
s.script = "scripts/test/test_chn_comm.txt"
print("testing chinese comment...")
s.run()
s.close()
def test_script_template():
app = App(bolt_url, user, password)
app.clear_all()
s = Script(app)
# TODO: template
s.close()