comparison tests/testProductIdRename.py @ 22:4004b67216a9

Add tests + method to change a ProductID
author Benoît Allard <benoit.allard@greenbone.net>
date Fri, 24 Oct 2014 16:16:50 +0200
parents
children e3ee542a89be
comparison
equal deleted inserted replaced
19:4b53e7bcff0d 22:4004b67216a9
1 import unittest
2
3 from datetime import datetime
4
5 from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship
6
7 class TestProductIdRename(unittest.TestCase):
8
9 def setUp(self):
10 self.doc = CVRF('title', 'type')
11 self.doc.setPublisher(CVRFPublisher('Other'))
12 initial = datetime.now()
13 current = datetime.now()
14 track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current)
15 track.addRevision(CVRFRevision((0,0), current, '1st'))
16 self.doc.setTracking(track)
17 self.doc.validate()
18
19
20 def testChangeProductId(self):
21 ptree = self.doc.createProductTree()
22 prod = CVRFFullProductName('1', 'a', ptree)
23 ptree.addProduct(prod)
24 vuln = CVRFVulnerability(1)
25 st = CVRFProductStatus('Fixed')
26 st.addProductID('1')
27 vuln.addProductStatus(st)
28 self.doc.addVulnerability(vuln)
29 self.doc.validate()
30 prod._productid = '2'
31 self.doc.changeProductID('1', '2')
32 self.doc.validate()
33
34 def testChangeProductIdRelation(self):
35 ptree = self.doc.createProductTree()
36 prod1 = CVRFFullProductName('1', 'a', ptree)
37 ptree.addProduct(prod1)
38 prod2 = CVRFFullProductName('2', 'b', ptree)
39 ptree.addProduct(prod2)
40 rel = CVRFRelationship('1', 'Installed On', '2')
41 ptree.addRelationship(rel)
42 self.doc.validate()
43 prod1._productid = '3'
44 self.doc.changeProductID('1', '3')
45 self.doc.validate()
46 prod2._productid = '1'
47 self.doc.changeProductID('2', '1')
48 self.doc.validate()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)