def test_semver_max(self): v1 = AppSemVer('1.0.0', True, datetime.now()) v2 = AppSemVer('1.0.0', True, datetime.now()) v3 = AppSemVer('0.9.9', True, datetime.now()) v4 = AppSemVer('1.0.0') versions = [v1, v3, v2, v4] self.assertEqual(v2, max(versions))
def _latest(self, releases): try: return max(releases, key=lambda r: AppSemVer(r.version, r.is_nightly, r.last_modified)) except ValueError: return None
def compatible_unstable_releases(self, platform_version, inclusive=True): """Returns all unstable releases of this app that are compatible with the given platform version. :param inclusive: Use inclusive version check (see AppRelease.is_compatible()). :return a sorted list of all compatible unstable releases. """ return sorted( filter( lambda r: r.is_compatible(platform_version, inclusive) and r. is_unstable, self.releases.all()), key=lambda r: AppSemVer(r.version, r.is_nightly, r.last_modified), reverse=True)
def test_semver_two_nightlies(self): d1 = datetime.now() time.sleep(.01) d2 = datetime.now() self.assertLess(AppSemVer('1.0.0', True, d1), AppSemVer('1.0.0', True, d2))
def test_semver_nightly_other(self): self.assertGreater(AppSemVer('1.0.0', True), AppSemVer('1.0.0'))
def test_semver_nightly(self): self.assertLess(AppSemVer('1.0.0'), AppSemVer('1.0.0', True))
def test_semver(self): self.assertLess(AppSemVer('1.0.0'), AppSemVer('1.0.1'))