comparison tests/testProducts.py @ 0:4a9f23230eba

Initial Release
author Benoît Allard <benoit.allard@greenbone.net>
date Wed, 24 Sep 2014 10:07:49 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4a9f23230eba
1 # -*- encoding: utf-8 -*-
2 # Description:
3 # Test suites to test the ProductTree
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 from farol.session import CVRFs
28
29 class TestBranches(TestCase):
30
31 def testCreateProduct(self):
32 self.createDoc('Title', 'Type')
33 self.app.post('/producttree/create', follow_redirects=True)
34 self.app.get('/producttree/product/add')
35 self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship=""))
36
37 def testCreateProductInTree(self):
38 rv = self.createDoc('Title', 'Type')
39 self.assertEqual(rv.status_code, 200)
40 self.app.post('/producttree/create')
41 self.assertFalse(CVRFs[self.id]._producttree is None)
42 self.app.get('/producttree/branch/add')
43 self.app.post('/producttree/branch/add', data=dict(type="Vendor", name="SecPod", parent=""))
44 self.app.get('/producttree/product/add')
45 self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="0", parent_relationship=""))
46 self.assertEqual(len(CVRFs[self.id]._producttree._products), 1)
47 prod = CVRFs[self.id]._producttree._products[0]
48 self.assertEqual(prod._parent.getPath(), ())
49
50 def testInsertProductInTree(self):
51 rv = self.createDoc('Title', 'Type')
52 self.assertEqual(rv.status_code, 200)
53 self.app.post('/producttree/create')
54 self.assertFalse(CVRFs[self.id]._producttree is None)
55 self.app.get('/producttree/product/add')
56 rv = self.app.post('/producttree/product/add', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship=""))
57 self.assertEqual(rv.status_code, 302)
58 self.app.get('/producttree/branch/add')
59 rv = self.app.post('/producttree/branch/add', data=dict(type="Vendor", name="SecPod", parent=""))
60 self.assertEqual(rv.status_code, 302)
61 self.app.get('/producttree/product/1131/edit')
62 rv = self.app.post('/producttree/product/1131/edit', data=dict(name="Name", productid="1131", cpe="", parent_branch="0", parent_relationship=""))
63 self.assertEqual(rv.status_code, 302)
64 rv = self.app.post('/producttree/product/1131/edit', data=dict(name="Name", productid="1131", cpe="", parent_branch="", parent_relationship=""))
65 self.assertEqual(rv.status_code, 302)
66
67 def testCreateProductInRelation(self):
68 rv = self.createDoc('Title', 'Type')
69 self.assertEqual(rv.status_code, 200)
70 self.app.post('/producttree/create')
71 self.assertFalse(CVRFs[self.id]._producttree is None)
72 self.app.post('/producttree/product/add', data=dict(name="Name 1", productid="1131", cpe="", parent_branch="", parent_relationship=""))
73 self.app.post('/producttree/product/add', data=dict(name="Name 2", productid="1132", cpe="", parent_branch="", parent_relationship=""))
74 self.app.get('/producttree/relationship/add')
75 self.app.post('/producttree/relationship/add', data=dict(productreference="1131", relationtype="as if", relatestoproductreference="1132"))
76 self.app.get('/')
77 self.app.get('/producttree/product/add')
78 self.app.post('/producttree/product/add', data=dict(name="Name 3", productid="1133", cpe="", parent_branch="", parent_relationship="0"))
79

http://farol.wald.intevation.org