def test_create_task_undo(self): user = self.create_user() task = Task(description='foobar', user=user) task.save() self.assertEqual(len(Undo.objects.all()), 1) self.assertNotIn('old', Undo.serialize()) self.assertEqual(len(Undo.serialize().splitlines()), 3) task.delete()
def test_edit_task_undo(self): user = self.create_user() task = Task(description='foobar', user=user) task.save() task.annotate('annotation') self.assertEqual(len(Undo.objects.all()), 2) self.assertIn('old', Undo.serialize()) # 'old' shouldn't have an annotation new_undo = Undo.objects.get(pk=2) self.assertNotIn('annotation_', new_undo.old) self.assertEqual(len(Undo.serialize().splitlines()), 7) self.assertNotIn('annotation_', Undo.serialize().splitlines()[4])
def get_taskdb(request, filename): if filename == 'pending.data': taskstr = Task.serialize('pending') elif filename == 'completed.data': taskstr = Task.serialize('completed') elif filename == 'undo.data': taskstr = Undo.serialize() else: return HttpResponseNotFound() response = HttpResponse(taskstr, mimetype='text/plain') response['Content-Length'] = len(taskstr) return response