示例#1
0
 def test_lt_rc_vs_pre(self):
     """Assert rc prereleases are greater than pre prereleases of the same version."""
     old_version = calver.CalendarVersion(version="2019.04.23-pre1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.23-rc1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#2
0
 def test_lt_two_prerelease_fields(self):
     """Assert prerelease fields are compared."""
     old_version = calver.CalendarVersion(version="2019.04.23-pre1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.23-pre2",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#3
0
 def test_lt_both_prerelease_one_unversioned(self):
     """Assert unversioned prereleases are less than versioned ones."""
     old_version = calver.CalendarVersion(version="2019.04.23-rc",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.23-rc1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#4
0
 def test_lt_beta_vs_alpha(self):
     """Assert beta prereleases are greater than alpha prereleases of the same version."""
     old_version = calver.CalendarVersion(version="2019.04.23-alpha1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.23-beta1",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#5
0
 def test_lt_prerelease_both_same(self):
     """Assert < always return false when version are the same."""
     version1 = calver.CalendarVersion(version="2019.04.23-alpha",
                                       pattern="YYYY.0M.DD-MODIFIER")
     version2 = calver.CalendarVersion(version="2019.04.23-alpha",
                                       pattern="YYYY.0M.DD-MODIFIER")
     self.assertFalse(version1 < version2)
     self.assertFalse(version2 < version1)
示例#6
0
 def test_lt_nonsense(self):
     """Assert CalendarVersion supports < comparison."""
     old_version = calver.CalendarVersion(version="2019.04.23junk",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.24",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#7
0
 def test_gt(self):
     """Assert CalendarVersion supports > comparison."""
     old_version = calver.CalendarVersion(version="2019.04.23",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.24",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(new_version > old_version)
     self.assertFalse(old_version > new_version)
示例#8
0
 def test_lt_years(self):
     """Assert CalendarVersion supports < comparison by years."""
     old_version = calver.CalendarVersion(version="2019.04.23",
                                          pattern="YYYY.0M.DD")
     new_version = calver.CalendarVersion(version="2020.04.23",
                                          pattern="YYYY.0M.DD")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#9
0
 def test_lt_nonsense(self):
     """Assert CalendarVersion supports < comparison."""
     # unclear if it should really be valid -junk modifier?
     old_version = calver.CalendarVersion(version="2019.04.23junk",
                                          pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.24",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#10
0
 def test_lt_one_prerelease_field(self):
     """Assert versions with prerelease fields are lesser than those that don't have them."""
     old_version = calver.CalendarVersion(
         version="2019.04.23-1-2_pre",
         pattern="YYYY.0M.DD-MINOR-MICRO_MODIFIER")
     new_version = calver.CalendarVersion(
         version="2019.04.23-1-2",
         pattern="YYYY.0M.DD-MINOR-MICRO_MODIFIER")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#11
0
 def test_lt_no_delimiter(self):
     """
     Assert CalendarVersion supports < comparison by full pattern.
     Bug https://github.com/fedora-infra/anitya/issues/867.
     """
     old_version = calver.CalendarVersion(version="20191018",
                                          pattern="YYYY0M0D")
     new_version = calver.CalendarVersion(version="20191213",
                                          pattern="YYYY0M0D")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#12
0
 def test_le(self):
     """Assert CalendarVersion supports <= comparison."""
     old_version = calver.CalendarVersion(version="2019.04.23",
                                          pattern="YYYY.0M.DD-MODIFIER")
     equally_old_version = calver.CalendarVersion(
         version="2019.04.23", pattern="YYYY.0M.DD-MODIFIER")
     new_version = calver.CalendarVersion(version="2019.04.24",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertTrue(old_version <= new_version)
     self.assertTrue(old_version <= equally_old_version)
     self.assertFalse(new_version <= old_version)
示例#13
0
 def test_split_pattern_0Y(self):
     """Assert that split function correctly parses 0Y release version pattern."""
     version = calver.CalendarVersion(version="09", pattern="0Y")
     expected = {
         "year": "09",
         "month": None,
         "day": None,
         "minor": None,
         "micro": None,
         "modifier": None,
         "rc_number": None,
     }
     self.assertEqual(version.split(), expected)
示例#14
0
 def test_split_ubuntu_pattern(self):
     """ Assert that Ubuntu version can be correctly split."""
     version = calver.CalendarVersion(version="18.04.1",
                                      pattern="YY.0M.MICRO")
     expected = {
         "year": "18",
         "month": "04",
         "day": None,
         "minor": None,
         "micro": "1",
         "modifier": None,
         "rc_number": None,
     }
     self.assertEqual(version.split(), expected)
示例#15
0
 def test_lt_days(self):
     """Assert CalendarVersion supports < comparison by days."""
     old_version = calver.CalendarVersion(version="23", pattern="DD")
     new_version = calver.CalendarVersion(version="24", pattern="DD")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#16
0
 def test_split_pattern_YY_not_a_number(self):
     """Assert that split function raises `ValueError` when version is not correct."""
     version = calver.CalendarVersion(version="aa", pattern="YY")
     self.assertRaises(ValueError, version.split)
示例#17
0
 def test_split_pattern_0D_too_short_version(self):
     """Assert that split function raises `ValueError` when version is too short."""
     version = calver.CalendarVersion(version="3", pattern="0D")
     self.assertRaises(ValueError, version.split)
示例#18
0
 def test_prerelease_multiple_filter(self):
     """Assert pre-releases will be valid if multiple filters is applied."""
     version = calver.CalendarVersion(version="2019.05.23",
                                      pattern="YYYY.0M.DD",
                                      pre_release_filter="05.;06.")
     self.assertTrue(version.prerelease())
示例#19
0
 def test_split_pattern_0D_incorrect_version_zero_padded(self):
     """Assert that split function raises `ValueError` when version is not correct."""
     version = calver.CalendarVersion(version="013", pattern="0D")
     self.assertRaises(ValueError, version.split)
示例#20
0
 def test_prerelease_prerelease_no_number(self):
     """Assert pre-releases without a number are still valid pre-releases."""
     for suffix in ("rc", "alpha", "beta", "dev", "pre"):
         version = calver.CalendarVersion(version="2019.04.23-" + suffix,
                                          pattern="YYYY.0M.DD-MODIFIER")
         self.assertTrue(version.prerelease())
示例#21
0
 def test_split_incorrect_delimiter(self):
     """ Assert that incorrect delimiter is detected."""
     version = calver.CalendarVersion(version="18.04-1",
                                      pattern="YY.0M.MICRO")
     self.assertRaises(ValueError, version.split)
示例#22
0
 def test_prerelease_with_number(self):
     """Assert versions with RC are prerelease versions."""
     for suffix in ("rc1", "alpha2", "beta10", "dev3", "pre999"):
         version = calver.CalendarVersion(version="2019.04.23-" + suffix,
                                          pattern="YYYY.0M.DD-MODIFIER")
         self.assertTrue(version.prerelease())
示例#23
0
 def test_split_missing_pattern(self):
     """Assert that split function raises exception when pattern is missing."""
     version = calver.CalendarVersion(version="2019.04.23")
     self.assertRaises(ValueError, version.split)
示例#24
0
 def test_prerelease_nonsense(self):
     """Assert prerelease is defined and returns False with nonsense versions."""
     version = calver.CalendarVersion(version="2019.04.23", pattern="AAAA")
     self.assertFalse(version.prerelease())
示例#25
0
 def test_split_nonsense_pattern(self):
     """Assert that split function raises exception when nonsense pattern is provided."""
     version = calver.CalendarVersion(version="2019.04.23", pattern="AAA")
     self.assertRaises(ValueError, version.split)
示例#26
0
 def test_lt_micro(self):
     """Assert CalendarVersion supports < comparison by micro version."""
     old_version = calver.CalendarVersion(version="1", pattern="MICRO")
     new_version = calver.CalendarVersion(version="2", pattern="MICRO")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)
示例#27
0
 def test_eq_wrong_type(self):
     """Assert CalendarVersion returns not implemented if other is not Version object."""
     new_version = calver.CalendarVersion(version="2019.04.23",
                                          pattern="YYYY.0M.DD-MODIFIER")
     self.assertEqual(new_version.__eq__("2019.04.23"), NotImplemented)
示例#28
0
 def test_lt_months(self):
     """Assert CalendarVersion supports < comparison by months."""
     old_version = calver.CalendarVersion(version="04.23", pattern="0M.DD")
     new_version = calver.CalendarVersion(version="05.23", pattern="0M.DD")
     self.assertTrue(old_version < new_version)
     self.assertFalse(new_version < old_version)