Mercurial > farol > farolluz
diff tests/testCPE.py @ 41:bb1dd2a55643
CPE: Add a generic 'parse' method
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Mon, 29 Dec 2014 14:58:29 +0100 |
parents | 1d9b2b06067e |
children |
line wrap: on
line diff
--- a/tests/testCPE.py Mon Dec 29 14:30:39 2014 +0100 +++ b/tests/testCPE.py Mon Dec 29 14:58:29 2014 +0100 @@ -1,6 +1,30 @@ +# -*- coding: utf-8 -*- +# Description: +# Tests for the CPE parsing methods +# +# Authors: +# BenoƮt Allard <benoit.allard@greenbone.net> +# +# Copyright: +# Copyright (C) 2014 Greenbone Networks GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + import unittest -from farolluz.parsers.cpe import CPE, CPEAttribute +from farolluz.parsers.cpe import CPE, CPEAttribute, parse class testbindToURI(unittest.TestCase): @@ -210,3 +234,16 @@ self.assertEqual(cpe.target_hw.value, "80gb") self.assertTrue(cpe.other.any) self.assertTrue(cpe.language.any) + +class testParse(unittest.TestCase): + + def testURI(self): + cpe = parse('cpe:/a:fogproject:fog:0.31') + self.assertEqual(cpe.part.value, 'a') + + def testFS(self): + cpe = parse('cpe:2.3:a:tenable:web_ui:2.3.3:*:*:*:*:*:*') + self.assertEqual(cpe.vendor.value, 'tenable') + + def testGarbage(self): + self.assertRaises(ValueError, parse, 'garbage')