# HG changeset patch # User Benoît Allard # Date 1412846247 -7200 # Node ID 95c79e518204c0e7ae4f772b52405957560c781e # Parent 80cd8f65e72b9fbefa089122fd62b83a0ce2ffdc Add tests diff -r 80cd8f65e72b -r 95c79e518204 tests/testDocument.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/testDocument.py Thu Oct 09 11:17:27 2014 +0200 @@ -0,0 +1,96 @@ +# -*- encoding: utf-8 -*- +# Description: +# Short Description +# +# Authors: +# Benoît Allard +# +# Copyright: +# Copyright (C) 2014 Greenbone Networks GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + +from .utils import TestCase + +class TestTracking(TestCase): + + def createTracking(self, id_): + return self.app.post('/document/tracking/edit', data={'id': id_, 'id_aliases': '', 'status': 'Draft', 'version': '0.0', 'initial': '2014-10-09T08:50:51+00:00', 'current': '2014-10-09T08:50:51+00:00', 'gen_engine': '', 'gen_date': ''}) + + def testCreateTracking(self): + rv = self.createDoc('Title', 'Type') + self.assertEqual(rv.status_code, 200) + rv = self.createTracking('5') + self.assertEqual(rv.status_code, 302) + + def testCreateEditDelRev(self): + rv = self.createDoc('Title', 'Type') + self.assertEqual(rv.status_code, 200) + rv = self.createTracking('5') + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/revision/add', data={'number': '0.0', 'date': '2014-10-09T08:57:52+00:00', 'description': "First Revision", 'update_tracking': 'on'}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/revision/0/edit', data={'number': '0.1', 'date': '2014-10-09T08:57:52+00:00', 'description': "First Revision"}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/revision/0/del') + self.assertEqual(rv.status_code, 302) + + +class testDocument(TestCase): + + def testCreateEditDelNote(self): + rv = self.createDoc('Title', 'Type') + self.assertEqual(rv.status_code, 200) + + rv = self.app.post('/document/note/add', data={'type': 'General', 'ordinal': '1', 'title': '', 'audience': '', 'note': 'Note content'}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/note/1/edit', data={'type': 'General', 'ordinal': '5', 'title': 'title', 'audience': '', 'note': 'Note content'}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/note/5/del') + self.assertEqual(rv.status_code, 302) + + + def testCreateEditDelRef(self): + rv = self.createDoc('Title', 'Type') + self.assertEqual(rv.status_code, 200) + + rv = self.app.post('/document/reference/add', data={'type': '', 'url': "https://example.com", 'description': "DOT com"}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/reference/0/edit', data={'type': 'External', 'url': "https://example.com", 'description': "example DOT com"}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/reference/0/del') + self.assertEqual(rv.status_code, 302) + + + def testCreateEditDelAck(self): + rv = self.createDoc('Title', 'Type') + self.assertEqual(rv.status_code, 200) + + rv = self.app.post('/document/acknowledgment/add', data={'names': "Antu Sanadi, Veerendra G.G", 'organizations': "SecPod Technologies Pvt. Ltd", 'description': "", 'url': ""}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/acknowledgment/0/edit', data={'names': "Antu Sanadi", 'organizations': "SecPod Technologies Pvt. Ltd", 'description': "Thanks !", 'url': ""}) + self.assertEqual(rv.status_code, 302) + + rv = self.app.post('/document/acknowledgment/0/del') + self.assertEqual(rv.status_code, 302) +