Browse code

check old_safe for consistency, fix pylint

Hanno Böck authored on22/12/2019 12:11:48
Showing1 changed files
... ...
@@ -6,6 +6,12 @@ import difflib
6 6
 import re
7 7
 
8 8
 
9
+def versioncompare(safe_version, find_version):
10
+    safe_version_tup = [int(x) for x in safe_version.split(".")]
11
+    find_version_tup = [int(x) for x in find_version.split(".")]
12
+    return find_version_tup < safe_version_tup
13
+
14
+
9 15
 class TestJsonLint(unittest.TestCase):
10 16
 
11 17
     @unittest.skipIf(sys.version_info < (3, 6, 0),
... ...
@@ -46,8 +52,19 @@ class TestJsonLint(unittest.TestCase):
46 52
                             or item['vuln'].startswith("https://"),
47 53
                             msg="%s: Invalid vuln %s" %
48 54
                             (item['name'], item['vuln']))
55
+
56
+            # make sure old_safe is properly sorted
57
+            if 'old_safe' in item:
58
+                old_safe = item['old_safe'].split(',')
59
+                for i in range(1, len(old_safe)):
60
+                    self.assertTrue(versioncompare(old_safe[i - 1],
61
+                                                   old_safe[i]),
62
+                                    msg="%s: Invalid old_safe ordering %s" %
63
+                                    (item['name'], item['old_safe']))
64
+
65
+            # subdir needs to be integer
49 66
             for det in item['detection']:
50
-                self.assertTrue(type(det['subdir']) == int,
67
+                self.assertTrue(isinstance(det['subdir'], int),
51 68
                                 msg="%s: subdir not int" % item['name'])
52 69
 
53 70