Пример #1
0
def matchVersion(ruleVersion, queryVersion, versionClass=MozillaVersion):
    """Decides whether a version from the rules matches an incoming version.
       If the ruleVersion is null, we match any queryVersion. If it's not
       null, we must either match exactly, or match a comparison operator."""
    logging.debug("ruleVersion: %s, queryVersion: %s", ruleVersion, queryVersion)
    if ruleVersion is None:
        return True
    rulesVersionList = ruleVersion.split(",")
    for rule in rulesVersionList:
        if version_compare(queryVersion, rule, versionClass):
            return True
    return False
Пример #2
0
def matchVersion(ruleVersion, queryVersion):
    """Decides whether a version from the rules matches an incoming version.
       If the ruleVersion is null, we match any queryVersion. If it's not
       null, we must either match exactly, or match a comparison operator."""
    logging.debug('ruleVersion: %s, queryVersion: %s', ruleVersion, queryVersion)
    if ruleVersion is None:
        return True
    rulesVersionList = ruleVersion.split(",")
    for rule in rulesVersionList:
        if version_compare(queryVersion, rule):
            return True
    return False
Пример #3
0
 def test_less_or_equal(self):
     self.assertTrue(version_compare('29.0', '<=30.0'))
     self.assertTrue(version_compare('30.0', '<=30.0'))
     self.assertFalse(version_compare('30.0.1', '<=30.0'))
Пример #4
0
 def test_less_than(self):
     self.assertTrue(version_compare('29.0', '<30.0'))
     self.assertFalse(version_compare('30.0', '<30.0'))
     self.assertFalse(version_compare('30.0.1', '<30.0'))
Пример #5
0
 def test_greater_than(self):
     self.assertFalse(version_compare('29.0', '>30.0'))
     self.assertFalse(version_compare('30.0', '>30.0'))
     self.assertTrue(version_compare('30.0.1', '>30.0'))
Пример #6
0
 def test_greater_or_equal(self):
     self.assertFalse(version_compare('29.0', '>=30.0'))
     self.assertTrue(version_compare('30.0', '>=30.0'))
     self.assertTrue(version_compare('30.0.1', '>=30.0'))
Пример #7
0
 def test_equality(self):
     # this isn't exhaustive, no need to redo all the MozillaVersion tests
     self.assertTrue(version_compare('30.0', '30.0'))
     self.assertTrue(version_compare('30.0.1', '30.0.1'))
     self.assertFalse(version_compare('30.0', '30.0.1'))
     self.assertFalse(version_compare('30.0.1', '30.0'))
Пример #8
0
 def test_less_or_equal(self):
     self.assertTrue(version_compare('29.0', '<=30.0'))
     self.assertTrue(version_compare('30.0', '<=30.0'))
     self.assertFalse(version_compare('30.0.1', '<=30.0'))
Пример #9
0
 def test_less_than(self):
     self.assertTrue(version_compare('29.0', '<30.0'))
     self.assertFalse(version_compare('30.0', '<30.0'))
     self.assertFalse(version_compare('30.0.1', '<30.0'))
Пример #10
0
 def test_greater_than(self):
     self.assertFalse(version_compare('29.0', '>30.0'))
     self.assertFalse(version_compare('30.0', '>30.0'))
     self.assertTrue(version_compare('30.0.1', '>30.0'))
Пример #11
0
 def test_greater_or_equal(self):
     self.assertFalse(version_compare('29.0', '>=30.0'))
     self.assertTrue(version_compare('30.0', '>=30.0'))
     self.assertTrue(version_compare('30.0.1', '>=30.0'))
Пример #12
0
 def test_equality(self):
     # this isn't exhaustive, no need to redo all the MozillaVersion tests
     self.assertTrue(version_compare('30.0', '30.0'))
     self.assertTrue(version_compare('30.0.1', '30.0.1'))
     self.assertFalse(version_compare('30.0', '30.0.1'))
     self.assertFalse(version_compare('30.0.1', '30.0'))