def test_lower_bound_filler(self): vr = _TINCProductVersionRange('[4.2-4.2.3.0]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.2.3.0')) vr = _TINCProductVersionRange('[-4.2.3.0]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('0.0.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.2.3.0')) #HotFix lower bound vr = _TINCProductVersionRange('[4.3.1.0LA1-]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) self.assertTrue(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.3.1.0LA1')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('main')) vr = _TINCProductVersionRange('(4.3.1.0LA1-)') self.assertFalse(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) self.assertFalse(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.3.1.0LA2')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('99.99.99.98'))
def test_version_range(self): vr = _TINCProductVersionRange('[4.2.1.0-4.2.3.0]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.1.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.2.3.0')) #HotFix Version range: Lowerbound check vr = _TINCProductVersionRange('[4.3.1.0LA1-]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.3.1.0LA1')) #HotFix Version range: Upperbound check vr = _TINCProductVersionRange('[-4.3.1.0LA1]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.1.0LA1'))
def test_with_multiple_product_version(self): tinc_test_case = MockTINCTestCaseWithProductVersionMetadata( 'test_with_multiple_product_version') self.assertIsNotNone(tinc_test_case.product_version) self.assertEquals( len(tinc_test_case.product_version.product_version_included), 2) self.assertTrue( 'test' in tinc_test_case.product_version.product_version_included) self.assertEquals( tinc_test_case.product_version.product_version_included['test'][0], _TINCProductVersionRange("[1.0.0.0-1.1.0.0]")) self.assertTrue( 'test2' in tinc_test_case.product_version.product_version_included) self.assertEquals( tinc_test_case.product_version.product_version_included['test2'] [0], _TINCProductVersionRange('(1.0.0.0 - 1.1.0.0)'))
def test_upper_bound_filler(self): vr = _TINCProductVersionRange('[4.2-4.3]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.99.99')) vr = _TINCProductVersionRange('[4.2-]') self.assertTrue(vr.lower_bound_inclusive and vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('main')) #HotFix upper bound filler vr = _TINCProductVersionRange('[-4.3.1.0LA1]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) self.assertTrue(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('0.0.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.1.0LA1'))
def test_exclusive_brackets(self): vr = _TINCProductVersionRange('(4.2.1.1-4.3)') self.assertFalse(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.1.2')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.99.98')) vr = _TINCProductVersionRange('(4.2.1.1-4.3]') self.assertFalse(vr.lower_bound_inclusive) self.assertTrue(vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.1.2')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.99.99')) vr = _TINCProductVersionRange('[4.2.1.1-4.3)') self.assertTrue(vr.lower_bound_inclusive) self.assertFalse(vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.2.1.1')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.99.98')) vr = _TINCProductVersionRange('(4.2.99.99-4.4.0.0)') self.assertFalse(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.3.0.0')) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.99.99')) #HotFix Version range exclusive bound check vr = _TINCProductVersionRange('(4.3.1.0LA1-)') self.assertFalse(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.lower_bound_version, _TINCProductVersion('4.3.1.0LA2')) vr = _TINCProductVersionRange('(-4.3.1.0LA1)') self.assertFalse(vr.lower_bound_inclusive or vr.upper_bound_inclusive) self.assertEquals(vr.upper_bound_version, _TINCProductVersion('4.3.1.0')) self.assertFalse(vr.match_version(_TINCProductVersion('4.3.1.0LA1')))
def test_match_version(self): vr = _TINCProductVersionRange('[4.2-4.4]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.0.0'))) self.assertTrue(vr.match_version(_TINCProductVersion('4.3.99.99'))) self.assertTrue(vr.match_version(_TINCProductVersion('4.2.0.0'))) self.assertTrue(vr.match_version(_TINCProductVersion('4.4.99.99'))) """ These cases are not expected. We will always compare with a four part version. self.assertTrue(vr.match_version(_TINCProductVersion('4.2'))) self.assertTrue(vr.match_version(_TINCProductVersion('4.2.1.x'))) self.assertFalse(vr.match_version(_TINCProductVersion('4.x'))) """ # Hotfix matches self.assertTrue(vr.match_version(_TINCProductVersion('4.2.0.0MS1'))) # A hotfix version is considered greater than the actual version self.assertFalse(vr.match_version(_TINCProductVersion('4.4.99.99MS1'))) vr = _TINCProductVersionRange('[4.2.6.0-9.99.99.99]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.0.0EFT'))) #Testing new range for the HOTFIX (4.3.1.0LA1)" vr = _TINCProductVersionRange('[4.3.1.0-]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) #Testing Version range with HotFix with lowerBound vr = _TINCProductVersionRange('[4.3.1.0LA1-]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) #Testing Version range with HotFix with upperBound vr = _TINCProductVersionRange('[-4.3.1.0LA1]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA1'))) #Testing Version range with HotFix vr = _TINCProductVersionRange('[4.3.1.0LA1-]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.1.0LA2'))) #Negative test case for version range with hotfix vr = _TINCProductVersionRange('[-4.3.1.0LA1]') self.assertFalse(vr.match_version(_TINCProductVersion('4.3.1.0LA2'))) #Hotfix range check with other hotfix version vr = _TINCProductVersionRange('[-4.3.0.1MA1]') self.assertTrue(vr.match_version(_TINCProductVersion('4.3.0.1LA2')))
def test_invalid_range(self): with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('test') with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('4.2-4.3') with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('[4.2-4.3') with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('[4.2]') with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('[4.2-4.3]test') # Lower bound > upper bound with self.assertRaises(TINCInvalidProductVersionException) as cm: vr = _TINCProductVersionRange('[4.2-4.1]')
def test_with_multiple_product_version(self): tinc_test_case = MockTINCTestCaseWithProductVersionMetadata('test_with_multiple_product_version') self.assertIsNotNone(tinc_test_case.product_version) self.assertEquals(len(tinc_test_case.product_version.product_version_included), 2) self.assertTrue('test' in tinc_test_case.product_version.product_version_included) self.assertEquals(tinc_test_case.product_version.product_version_included['test'][0], _TINCProductVersionRange("[1.0.0.0-1.1.0.0]")) self.assertTrue('test2' in tinc_test_case.product_version.product_version_included) self.assertEquals(tinc_test_case.product_version.product_version_included['test2'][0], _TINCProductVersionRange('(1.0.0.0 - 1.1.0.0)'))