0
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
2 # Description: |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
3 # Test suites to test the ProductTree |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
4 # |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
5 # Authors: |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
6 # BenoƮt Allard <benoit.allard@greenbone.net> |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
7 # |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
8 # Copyright: |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
9 # Copyright (C) 2014 Greenbone Networks GmbH |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
10 # |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
11 # This program is free software; you can redistribute it and/or |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
12 # modify it under the terms of the GNU General Public License |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
13 # as published by the Free Software Foundation; either version 2 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
14 # of the License, or (at your option) any later version. |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
15 # |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
16 # This program is distributed in the hope that it will be useful, |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
19 # GNU General Public License for more details. |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
20 # |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
21 # You should have received a copy of the GNU General Public License |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
22 # along with this program; if not, write to the Free Software |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
23 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
24 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
25 from .utils import TestCase |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
26 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
27 from farol.session import CVRFs |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
28 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
29 class TestBranches(TestCase): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
30 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
31 def testCreateProduct(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
32 self.createDoc('Title', 'Type') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
33 self.app.post('/producttree/create', follow_redirects=True) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
34 self.app.get('/producttree/product/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
35 self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
36 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
37 def testCreateProductInTree(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
38 rv = self.createDoc('Title', 'Type') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
39 self.assertEqual(rv.status_code, 200) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
40 self.app.post('/producttree/create') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
41 self.assertFalse(CVRFs[self.id]._producttree is None) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
42 self.app.get('/producttree/branch/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
43 self.app.post('/producttree/branch/add', data=dict(type="Vendor", name="SecPod", parent="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
44 self.app.get('/producttree/product/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
45 self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="0", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
46 self.assertEqual(len(CVRFs[self.id]._producttree._products), 1) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
47 prod = CVRFs[self.id]._producttree._products[0] |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
48 self.assertEqual(prod._parent.getPath(), ()) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
49 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
50 def testInsertProductInTree(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
51 rv = self.createDoc('Title', 'Type') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
52 self.assertEqual(rv.status_code, 200) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
53 self.app.post('/producttree/create') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
54 self.assertFalse(CVRFs[self.id]._producttree is None) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
55 self.app.get('/producttree/product/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
56 rv = self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
57 self.assertEqual(rv.status_code, 302) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
58 self.app.get('/producttree/branch/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
59 rv = self.app.post('/producttree/branch/add', data=dict(type="Vendor", name="SecPod", parent="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
60 self.assertEqual(rv.status_code, 302) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
61 self.app.get('/producttree/product/1131/edit') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
62 rv = self.app.post('/producttree/product/1131/edit', data=dict(name="Name", productid="1131", cpe="", parent_branch="0", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
63 self.assertEqual(rv.status_code, 302) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
64 rv = self.app.post('/producttree/product/1131/edit', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
65 self.assertEqual(rv.status_code, 302) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
66 |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
67 def testCreateProductInRelation(self): |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
68 rv = self.createDoc('Title', 'Type') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
69 self.assertEqual(rv.status_code, 200) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
70 self.app.post('/producttree/create') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
71 self.assertFalse(CVRFs[self.id]._producttree is None) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
72 self.app.post('/producttree/product/add', data=dict(name="Name 1", productid="1131", cpe="", parent_branch="", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
73 self.app.post('/producttree/product/add', data=dict(name="Name 2", productid="1132", cpe="", parent_branch="", parent_relationship="")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
74 self.app.get('/producttree/relationship/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
75 self.app.post('/producttree/relationship/add', data=dict(productreference="1131", relationtype="as if", relatestoproductreference="1132")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
76 self.app.get('/') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
77 self.app.get('/producttree/product/add') |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
78 self.app.post('/producttree/product/add', data=dict(name="Name 3", productid="1133", cpe="", parent_branch="", parent_relationship="0")) |
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff
changeset
|
79 |