91
91
self.context.include = unicode(include)
92
92
self.context.num_rows = int(num_rows)
93
93
return {'result': 'moo'}
95
@named_operation(u'edit')
96
def delete_exercise(self, req, id):
98
if self.context.worksheets.count() is not 0:
101
#XXX: Not sure if this works
102
for suite in req.context.test_suites:
103
for variable in suite.variables:
104
req.store.remove(variable)
105
for test_case in suite.test_cases:
106
for test_part in test_case.parts:
107
req.store.remove(test_part)
108
req.store.remove(test_case)
109
req.store.remove(suite)
111
req.store.remove(self.context)
112
return {'result': 'ok'}
95
114
@named_operation(u'edit')
96
115
def add_suite(self, req, description, function, stdin):
121
140
suite.stdin = unicode(stdin)
123
142
return {'result': 'ok'}
144
@named_operation(u'edit')
145
def delete_suite(self, req, suiteid):
147
suite = req.store.find(TestSuite,
148
TestSuite.suiteid == int(suiteid),
149
TestSuite.exercise_id == self.context.id).one()
153
for variable in suite.variables:
154
req.store.remove(variable)
155
for test_case in suite.test_cases:
156
for test_part in test_case.parts:
157
req.store.remove(test_part)
158
req.store.remove(test_case)
159
req.store.remove(suite)
161
return {'result': 'ok'}
125
163
@named_operation(u'edit')
126
164
def add_var(self, req, suiteid, var_type, var_name, var_val, argno):
180
230
req.store.add(new_case)
182
232
return {'result': 'ok'}
234
@named_operation(u'edit')
235
def edit_testcase(self, req, suiteid, testid, passmsg, failmsg, default):
237
suite = req.store.find(TestSuite,
238
TestSuite.suiteid == int(suiteid),
239
TestSuite.exercise_id == self.context.id).one()
241
raise NotFound('testsuite')
243
test_case = req.store.find(TestCase,
244
TestCase.suiteid == suite.suiteid,
245
TestCase.testid == int(testid)).one()
246
if test_case is None:
247
raise NotFound('testcase')
249
test_case.passmsg = unicode(passmsg)
250
test_case.failmsg = unicode(failmsg)
251
test_case.default = unicode(default)
253
return {'result': 'ok'}
255
@named_operation(u'edit')
256
def delete_testcase(self, req, suiteid, testid):
258
suite = req.store.find(TestSuite,
259
TestSuite.suiteid == int(suiteid),
260
TestSuite.exercise_id == self.context.id).one()
264
test_case = req.store.find(TestCase,
265
TestCase.suiteid == suite.suiteid,
266
TestCase.testid == int(testid)).one()
267
if test_case is None:
270
for test_part in test_case.parts:
271
req.store.remove(test_part)
272
req.store.remove(test_case)
274
return {'result': 'ok'}
276
@named_operation(u'edit')
277
def edit_testpart(self, req, suiteid, testid, partid, part_type, test_type,
280
suite = req.store.find(TestSuite,
281
TestSuite.suiteid == int(suiteid),
282
TestSuite.exercise_id == self.context.id).one()
284
raise NotFound('testsuite')
286
test_case = req.store.find(TestCase,
287
TestCase.suiteid == suite.suiteid,
288
TestCase.testid == int(testid)).one()
289
if test_case is None:
290
raise NotFound('testcase')
292
test_part = req.store.find(TestCasePart,
293
TestCasePart.testid == test_case.testid,
294
TestCasePart.partid == int(partid)).one()
295
if test_part is None:
296
raise NotFound('testcasepart')
298
test_part.part_type = unicode(part_type)
299
test_part.test_type = unicode(test_type)
300
test_part.data = unicode(data)
301
test_part.filename = unicode(filename)
303
return {'result': 'ok'}
305
@named_operation(u'edit')
306
def add_testpart(self, req, suiteid, testid, part_type, test_type,
309
suite = req.store.find(TestSuite,
310
TestSuite.suiteid == int(suiteid),
311
TestSuite.exercise_id == self.context.id).one()
313
raise NotFound('testsuite')
315
test_case = req.store.find(TestCase,
316
TestCase.suiteid == suite.suiteid,
317
TestCase.testid == int(testid)).one()
318
if test_case is None:
319
raise NotFound('testcase')
321
test_part = TestCasePart()
322
test_part.part_type = unicode(part_type)
323
test_part.test_type = unicode(test_type)
324
test_part.data = unicode(data)
325
test_part.filename = unicode(filename)
327
test_case.parts.add(test_part)
329
return {'result': 'ok'}
331
@named_operation(u'edit')
332
def delete_testpart(self, req, suiteid, testid, partid):
333
suite = req.store.find(TestSuite,
334
TestSuite.suiteid == int(suiteid),
335
TestSuite.exercise_id == self.context.id).one()
339
test_case = req.store.find(TestCase,
340
TestCase.suiteid == suite.suiteid,
341
TestCase.testid == int(testid)).one()
342
if test_case is None:
345
test_part = req.store.find(TestCasePart,
346
TestCasePart.testid == test_case.testid,
347
TestCasePart.partid == int(partid)).one()
348
if test_part is None:
349
raise NotFound('testcasepart')
351
req.store.remove(test_part)
353
return {'result': 'ok'}