comparison tests/testDocument.py @ 75:95c79e518204

Add tests
author Benoît Allard <benoit.allard@greenbone.net>
date Thu, 09 Oct 2014 11:17:27 +0200
parents
children
comparison
equal deleted inserted replaced
74:80cd8f65e72b 75:95c79e518204
1 # -*- encoding: utf-8 -*-
2 # Description:
3 # Short Description
4 #
5 # Authors:
6 # BenoƮt Allard <benoit.allard@greenbone.net>
7 #
8 # Copyright:
9 # Copyright (C) 2014 Greenbone Networks GmbH
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 from .utils import TestCase
26
27 class TestTracking(TestCase):
28
29 def createTracking(self, id_):
30 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': ''})
31
32 def testCreateTracking(self):
33 rv = self.createDoc('Title', 'Type')
34 self.assertEqual(rv.status_code, 200)
35 rv = self.createTracking('5')
36 self.assertEqual(rv.status_code, 302)
37
38 def testCreateEditDelRev(self):
39 rv = self.createDoc('Title', 'Type')
40 self.assertEqual(rv.status_code, 200)
41 rv = self.createTracking('5')
42 self.assertEqual(rv.status_code, 302)
43
44 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'})
45 self.assertEqual(rv.status_code, 302)
46
47 rv = self.app.post('/document/revision/0/edit', data={'number': '0.1', 'date': '2014-10-09T08:57:52+00:00', 'description': "First Revision"})
48 self.assertEqual(rv.status_code, 302)
49
50 rv = self.app.post('/document/revision/0/del')
51 self.assertEqual(rv.status_code, 302)
52
53
54 class testDocument(TestCase):
55
56 def testCreateEditDelNote(self):
57 rv = self.createDoc('Title', 'Type')
58 self.assertEqual(rv.status_code, 200)
59
60 rv = self.app.post('/document/note/add', data={'type': 'General', 'ordinal': '1', 'title': '', 'audience': '', 'note': 'Note content'})
61 self.assertEqual(rv.status_code, 302)
62
63 rv = self.app.post('/document/note/1/edit', data={'type': 'General', 'ordinal': '5', 'title': 'title', 'audience': '', 'note': 'Note content'})
64 self.assertEqual(rv.status_code, 302)
65
66 rv = self.app.post('/document/note/5/del')
67 self.assertEqual(rv.status_code, 302)
68
69
70 def testCreateEditDelRef(self):
71 rv = self.createDoc('Title', 'Type')
72 self.assertEqual(rv.status_code, 200)
73
74 rv = self.app.post('/document/reference/add', data={'type': '', 'url': "https://example.com", 'description': "DOT com"})
75 self.assertEqual(rv.status_code, 302)
76
77 rv = self.app.post('/document/reference/0/edit', data={'type': 'External', 'url': "https://example.com", 'description': "example DOT com"})
78 self.assertEqual(rv.status_code, 302)
79
80 rv = self.app.post('/document/reference/0/del')
81 self.assertEqual(rv.status_code, 302)
82
83
84 def testCreateEditDelAck(self):
85 rv = self.createDoc('Title', 'Type')
86 self.assertEqual(rv.status_code, 200)
87
88 rv = self.app.post('/document/acknowledgment/add', data={'names': "Antu Sanadi, Veerendra G.G", 'organizations': "SecPod Technologies Pvt. Ltd", 'description': "", 'url': ""})
89 self.assertEqual(rv.status_code, 302)
90
91 rv = self.app.post('/document/acknowledgment/0/edit', data={'names': "Antu Sanadi", 'organizations': "SecPod Technologies Pvt. Ltd", 'description': "Thanks !", 'url': ""})
92 self.assertEqual(rv.status_code, 302)
93
94 rv = self.app.post('/document/acknowledgment/0/del')
95 self.assertEqual(rv.status_code, 302)
96

http://farol.wald.intevation.org