Repository navigation
Expand file tree
/
Copy pathinspect
More file actions
295 lines (213 loc) · 7.42 KB
/
Copy pathinspect
File metadata and controls
295 lines (213 loc) · 7.42 KB
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#
# Inspect, tools to inspect a kmom.
#
# Usage: dbwebb inspect kmom01
#
# Sequence executed:
# python(), pythonkmom01(), pythonlast()
#
#
# Test python general, always executed first
#
python()
{
inspectIntro
}
#
# Test general, always executed last in sequence
#
pythonlast()
{
inspectMe "me/redovisa" "me.html" "redovisning.html" "" "redovisa"
}
#
# Test python kmom01
#
pythonkmom01()
{
inspectLab "uppgift/python-med-varden-och-variabler" "lab1" "answer.py" "python3 answer.py"
inspectExerciseHeader "plane" "uppgift/ditt-forsta-python-skript" "$KMOM/plane"
inspectCommand "plane.py" "$EXEC_DIR/$KMOM/plane" "python3 plane.py"
viewFileContent "plane.py" "me/$KMOM/plane"
}
#
# Test python kmom02
#
pythonkmom02()
{
inspectLab "uppgift/python-med-villkor-och-loopar" "lab2" "answer.py" "python3 answer.py"
inspectExerciseHeader "marvin1" "uppgift/din-egen-chattbot-marvin-steg-1-v2" "$KMOM/marvin1"
inspectCommand "marvin.py" "$EXEC_DIR/$KMOM/marvin1" "python3 marvin.py"
viewFileContent "marvin.py" "me/$KMOM/marvin1"
}
#
# Test python kmom03
#
pythonkmom03()
{
inspectLab "uppgift/python-listor-v2" "lab3" "answer.py" "python3 answer.py"
inspectExerciseHeader "marvin2" "uppgift/din-egen-chattbot-marvin-steg-2-v3" "$KMOM/marvin2"
inspectCommand "marvin.py" "$EXEC_DIR/$KMOM/marvin2" "python3 marvin.py"
}
#
# Test python kmom04
#
pythonkmom04()
{
inspectLab "uppgift/python-med-funktioner-och-moduler-v2" "lab4" "answer.py" "python3 answer.py"
inspectExerciseHeader "marvin3" "uppgift/din-egen-chattbot-marvin-steg-3-v3" "$KMOM/marvin3"
inspectCommand "main.py" "$EXEC_DIR/$KMOM/marvin3" "python3 main.py"
}
#
# Test python kmom05
#
pythonkmom05()
{
inspectLab "uppgift/python-med-dictionaries-och-tupler-v2" "lab5" "answer.py" "python3 answer.py"
inspectExerciseHeader "marvin4" "uppgift/din-egen-chattbot-marvin-utslapp" "$KMOM/marvin4"
inspectCommand "main.py" "$EXEC_DIR/$KMOM/marvin4" "python3 main.py"
}
#
# Test python kmom06
#
pythonkmom06()
{
inspectLab "uppgift/python-med-dictionaries-och-tupler" "lab6" "answer.py" "python3 answer.py"
inspectExerciseHeader "analyzer" "uppgift/analysera-text-och-ord-v2" "$KMOM/analyzer"
inspectCommand "../main.py" "$EXEC_DIR/$KMOM/analyzer/.dbwebb" "./correct.bash"
viewFileContent "main.py" "me/$KMOM/analyzer"
viewFileContent "analyzer.py" "me/$KMOM/analyzer"
}
#
# Test python kmom10
#
pythonkmom10()
{
# Updated "exam" when new examination
local exam="try3"
inspectCommand "../exam.py" "$EXEC_DIR/$KMOM/$exam/.dbwebb/" "./correct.bash"
viewFileContent "exam.py" "me/$KMOM/$exam"
RECEIPT_FILE=$(ls -t $EXEC_DIR/$KMOM/$exam/.dbwebb/exam/receipt | head -2 | tail -1)
viewFileContent "$RECEIPT_FILE" "me/$KMOM/$exam/.dbwebb/exam/receipt"
# If sha1sum is installed
sha1sum --version >/dev/null 2>&1 && pythonexamchecksum $exam
}
#
# Test checksum for test_dbwebb.py and correct.bash
#
pythonexamchecksum()
{
local exam=$1
# Uppdatera real_sha för ny examination
# local real_sha="06582baa7a82dc2a770588c578d810f72505769113667f0cdf8e921e909c92a563ea56dff0a6ab3c" # prep
# local real_sha="fa1bae3ddede93768751943589c02c4de413720002ff34ebe55e75d36a272e0c259683ee81a0dd65" # try1
# local real_sha="6ae09055de67eeee449508cfa03abc1be597bb240f51475610acc29cd133a92ff491499d3dc6f4f7" # try2
# local real_sha="137de528cc2f281b0bd9c091e19d47dc854e5c360be1ef26aa845cc6ba0d94acc2eb1ddfe43f2100" # try3
# local real_sha="4b9a0dc304c2e3b0fb51e6d2399d535c62f7aa58e6adfa79ab2eab1dae2b87e802e42f2a1bc4c981" # try1
# local real_sha="083126dc7aa532f01afa46dc8769d031b3b594e69d717aa3b2b7a8d2fd91d4753596d0d1ee26f3ad" # try2
local real_sha="96366da688fe7787ca6731a371055f5a6b7ade8daea35e693dfd0e2bf631cf6f60b67fa9208235cf" # try3
local their_sha="$(cat $EXEC_DIR/$KMOM/$exam/.dbwebb/test_dbwebb.py | sha1sum | awk '{print $1}')$(cat $EXEC_DIR/$KMOM/$exam/.dbwebb/correct.bash | sha1sum | awk '{print $1}')"
echo ""
if [ "$real_sha" = "$their_sha" ];then
echo "SHA1 matches!"
assert 1 "test" "Command executed successfully."
printf "\n$MSG_OK Command executed with a exit status 0 - indicating success."
printf "\n"
else
echo "SHA1 does not match!"
echo "Real: $real_sha"
echo "Their: $their_sha"
assert 0 "test" "Command returned non-zero exit status which might indicate failure."
viewFileContent "test_dbwebb.py" "me/$KMOM/$exam/.dbwebb"
viewFileContent "correct.bash" "me/$KMOM/$exam/.dbwebb"
fi
}
# ----------------------------------------------------------------------
#
# Test python marvin5
#
pythonmarvin5()
{
local lab="$1"
local main="$2"
local url="$3"
local target="me/$KMOM/$lab"
local where="$EXEC_DIR/$KMOM/$lab"
headerForTest "-- $lab" "-- ${DBW_WWW}$url"
openFilesInEditor "$target"
checkKmomDir "$target"
# Exit status
# assertExit 0 "cd $where; python3 $main --version" "Should return exit status 0 but did not."
# assertExit 1 "cd $where; python3 $main --MISSINGOPTION" "Should return exit status 1 but did not."
# General options
opts="--help"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--version"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# Ping
opts="ping ${DBW_WWW}humans.txt"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="ping-history"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# Get
opts="get ${DBW_WWW}blogg/introduktionsveckan-2017"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--output=humans.txt get ${DBW_WWW}blogg/introduktionsveckan-2017"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
assert 0 "test -f $where/humans.txt" "File humans.txt is missing."
cat "$where/humans.txt"
# Quote
opts="quote"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# <title>
opts="title http://dbwebb.se"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# analyzer2
opts="all humans.txt"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# analyzer2 lines
opts="lines humans.txt"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
}
#
# Test python adventure
#
pythonAdventure()
{
local lab="$1"
local main="$2"
local url="$3"
local target="me/$KMOM/$lab"
local where="$EXEC_DIR/$KMOM/$lab"
headerForTest "-- $lab" "-- ${DBW_WWW}$url"
openFilesInEditor "$target"
checkKmomDir "$target"
# Options
opts="--help"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--version"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--info"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--about"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
opts="--cheat"
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
# run it
opts=""
inspectCommand "$main" "$where" "python3 $main $opts" "$opts"
}
#
# Test python lab & marvin
#
pythonexercise()
{
local lab="$1"
local main="$2"
local url="$3"
local target="me/$KMOM/$lab"
headerForTest "-- $lab" "-- ${DBW_WWW}$url"
openFilesInEditor "$target"
checkKmomDir "$target"
inspectCommand "$main" "$EXEC_DIR/$KMOM/$lab" "python3 $main"
}