annotate tests/testProductIdRename.py @ 29:e3ee542a89be

Refactor tests dir
author Benoît Allard <benoit.allard@greenbone.net>
date Mon, 27 Oct 2014 11:48:42 +0100
parents 4004b67216a9
children
rev   line source
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
1 from datetime import datetime
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
2
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
3 from tests.utils import TestCase
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
4 from farolluz.cvrf import CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
5
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
6 class TestProductIdRename(TestCase):
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
7
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
8 def testChangeProductId(self):
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
9 ptree = self.doc.createProductTree()
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
10 prod = CVRFFullProductName('1', 'a', ptree)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
11 ptree.addProduct(prod)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
12 vuln = CVRFVulnerability(1)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
13 st = CVRFProductStatus('Fixed')
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
14 st.addProductID('1')
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
15 vuln.addProductStatus(st)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
16 self.doc.addVulnerability(vuln)
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
17 self._validate()
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
18 prod._productid = '2'
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
19 self.doc.changeProductID('1', '2')
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
20 self._validate()
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
21
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
22 def testChangeProductIdRelation(self):
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
23 ptree = self.doc.createProductTree()
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
24 prod1 = CVRFFullProductName('1', 'a', ptree)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
25 ptree.addProduct(prod1)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
26 prod2 = CVRFFullProductName('2', 'b', ptree)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
27 ptree.addProduct(prod2)
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
28 rel = CVRFRelationship('1', 'Installed On', '2')
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
29 ptree.addRelationship(rel)
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
30 self._validate()
22
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
31 prod1._productid = '3'
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
32 self.doc.changeProductID('1', '3')
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
33 self.doc.validate()
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
34 prod2._productid = '1'
4004b67216a9 Add tests + method to change a ProductID
Benoît Allard <benoit.allard@greenbone.net>
parents:
diff changeset
35 self.doc.changeProductID('2', '1')
29
e3ee542a89be Refactor tests dir
Benoît Allard <benoit.allard@greenbone.net>
parents: 22
diff changeset
36 self._validate()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)