benoit@22: import unittest benoit@22: benoit@22: from datetime import datetime benoit@22: benoit@22: from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship benoit@22: benoit@22: class TestProductIdRename(unittest.TestCase): benoit@22: benoit@22: def setUp(self): benoit@22: self.doc = CVRF('title', 'type') benoit@22: self.doc.setPublisher(CVRFPublisher('Other')) benoit@22: initial = datetime.now() benoit@22: current = datetime.now() benoit@22: track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current) benoit@22: track.addRevision(CVRFRevision((0,0), current, '1st')) benoit@22: self.doc.setTracking(track) benoit@22: self.doc.validate() benoit@22: benoit@22: benoit@22: def testChangeProductId(self): benoit@22: ptree = self.doc.createProductTree() benoit@22: prod = CVRFFullProductName('1', 'a', ptree) benoit@22: ptree.addProduct(prod) benoit@22: vuln = CVRFVulnerability(1) benoit@22: st = CVRFProductStatus('Fixed') benoit@22: st.addProductID('1') benoit@22: vuln.addProductStatus(st) benoit@22: self.doc.addVulnerability(vuln) benoit@22: self.doc.validate() benoit@22: prod._productid = '2' benoit@22: self.doc.changeProductID('1', '2') benoit@22: self.doc.validate() benoit@22: benoit@22: def testChangeProductIdRelation(self): benoit@22: ptree = self.doc.createProductTree() benoit@22: prod1 = CVRFFullProductName('1', 'a', ptree) benoit@22: ptree.addProduct(prod1) benoit@22: prod2 = CVRFFullProductName('2', 'b', ptree) benoit@22: ptree.addProduct(prod2) benoit@22: rel = CVRFRelationship('1', 'Installed On', '2') benoit@22: ptree.addRelationship(rel) benoit@22: self.doc.validate() benoit@22: prod1._productid = '3' benoit@22: self.doc.changeProductID('1', '3') benoit@22: self.doc.validate() benoit@22: prod2._productid = '1' benoit@22: self.doc.changeProductID('2', '1') benoit@22: self.doc.validate()