diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/testProductIdRename.py	Fri Oct 24 16:16:50 2014 +0200
@@ -0,0 +1,48 @@
+import unittest
+
+from datetime import datetime
+
+from farolluz.cvrf import CVRF, CVRFPublisher, CVRFTracking, CVRFTrackingID, CVRFRevision, CVRFFullProductName, CVRFVulnerability, CVRFProductStatus, CVRFRelationship
+
+class TestProductIdRename(unittest.TestCase):
+
+    def setUp(self):
+        self.doc = CVRF('title', 'type')
+        self.doc.setPublisher(CVRFPublisher('Other'))
+        initial = datetime.now()
+        current = datetime.now()
+        track = CVRFTracking(CVRFTrackingID('1234'), 'Draft', (0,0), initial, current)
+        track.addRevision(CVRFRevision((0,0), current, '1st'))
+        self.doc.setTracking(track)
+        self.doc.validate()
+
+
+    def testChangeProductId(self):
+        ptree = self.doc.createProductTree()
+        prod = CVRFFullProductName('1', 'a', ptree)
+        ptree.addProduct(prod)
+        vuln = CVRFVulnerability(1)
+        st = CVRFProductStatus('Fixed')
+        st.addProductID('1')
+        vuln.addProductStatus(st)
+        self.doc.addVulnerability(vuln)
+        self.doc.validate()
+        prod._productid = '2'
+        self.doc.changeProductID('1', '2')
+        self.doc.validate()
+
+    def testChangeProductIdRelation(self):
+        ptree = self.doc.createProductTree()
+        prod1 = CVRFFullProductName('1', 'a', ptree)
+        ptree.addProduct(prod1)
+        prod2 = CVRFFullProductName('2', 'b', ptree)
+        ptree.addProduct(prod2)
+        rel = CVRFRelationship('1', 'Installed On', '2')
+        ptree.addRelationship(rel)
+        self.doc.validate()
+        prod1._productid = '3'
+        self.doc.changeProductID('1', '3')
+        self.doc.validate()
+        prod2._productid = '1'
+        self.doc.changeProductID('2', '1')
+        self.doc.validate()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)