def test_without_suffix(self): self.assertEqual( (0, 0, 0, True, "None"), to_compare_key(ApplicationVersion(0, 0, 0))) self.assertEqual( (1, 2, 3, True, "None"), to_compare_key(ApplicationVersion(1, 2, 3)))
def test_with_suffix(self): self.assertEqual( (1, 2, 3, False, "Alpha"), to_compare_key(ApplicationVersion(1, 2, 3, "Alpha"))) self.assertEqual( (1, 2, 3, False, "Beta"), to_compare_key(ApplicationVersion(1, 2, 3, "Beta")))
def test_properties(self): version = ApplicationVersion(1, 2, 3) self.assertEqual(1, version.major) self.assertEqual(2, version.minor) self.assertEqual(3, version.patch) self.assertEqual(None, version.suffix) version = ApplicationVersion(1, 2, 3, "SNAPSHOT") self.assertEqual(1, version.major) self.assertEqual(2, version.minor) self.assertEqual(3, version.patch) self.assertEqual("SNAPSHOT", version.suffix)
def test_constructor(self): self.assertEqual( "1.2.3", str(ApplicationVersion(1, 2, 3))) # TODO ##self.assertEqual( ## "1.2.3", ## str(ApplicationVersion(1, 2, 3, ""))) self.assertEqual( "1.2.3", str(ApplicationVersion(1, 2, 3, None))) self.assertEqual( "1.2.3-SNAPSHOT", str(ApplicationVersion(1, 2, 3, "SNAPSHOT"))) self.assertEqual( "1.2.3-Alpha", str(ApplicationVersion(1, 2, 3, "Alpha")))
def initialize(context, version): """ アプリケーションのバージョンを初期化する. Arguments --------- version : str バージョン文字列. Ex. "1.2.3-SNAPSHOT" """ version = ApplicationVersion.from_version_string(version) version.save(VERSION_FILE_PATH) print("set version to {}".format(version))
def _bump_application_version(bump_method): """ アプリケーションのバージョンを変更する. Arguments --------- bump_method : instancemethod バージョンを変更する ApplicationVersion のメソッド. Ex. ApplicationVersion.bump_major """ old_version = ApplicationVersion.from_file(VERSION_FILE_PATH) new_version = bump_method(old_version) new_version.save(VERSION_FILE_PATH) print("bump version {} to {}".format(old_version, new_version))
def show(context): """ アプリケーションのバージョンを表示する. """ version = ApplicationVersion.from_file(VERSION_FILE_PATH) print(version)
def test_eq(self): self.assertEqual(True, ApplicationVersion(1, 2, 3) == ApplicationVersion(1, 2, 3)) self.assertEqual(False, ApplicationVersion(1, 2, 3) == ApplicationVersion(1, 2, 4)) self.assertEqual(False, ApplicationVersion(1, 2, 4) == ApplicationVersion(1, 2, 3)) self.assertEqual(False, ApplicationVersion(1, 2, 3) == ApplicationVersion(1, 2, 3, "SNAPSHOT")) self.assertEqual(False, ApplicationVersion(1, 2, 3) == ApplicationVersion(1, 2, 4, "SNAPSHOT")) self.assertEqual(False, ApplicationVersion(1, 2, 4) == ApplicationVersion(1, 2, 3, "SNAPSHOT")) self.assertEqual(False, ApplicationVersion(1, 2, 3, "SNAPSHOT") == ApplicationVersion(1, 2, 3)) self.assertEqual(False, ApplicationVersion(1, 2, 3, "SNAPSHOT") == ApplicationVersion(1, 2, 4)) self.assertEqual(False, ApplicationVersion(1, 2, 4, "SNAPSHOT") == ApplicationVersion(1, 2, 3)) self.assertEqual(True, ApplicationVersion(1, 2, 3, "SNAPSHOT") == ApplicationVersion(1, 2, 3, "SNAPSHOT")) self.assertEqual(False, ApplicationVersion(1, 2, 3, "SNAPSHOT") == ApplicationVersion(1, 2, 4, "SNAPSHOT")) self.assertEqual(False, ApplicationVersion(1, 2, 4, "SNAPSHOT") == ApplicationVersion(1, 2, 3, "SNAPSHOT"))
def test_bump_to_release(self): version = ApplicationVersion(1, 2, 3, "SNAPSHOT") new_version = version.bump_to_release() self.assertEqual("1.2.3-SNAPSHOT", str(version)) self.assertEqual("1.2.3", str(new_version))
def test_bump_to_snapshot(self): version = ApplicationVersion(1, 2, 3) new_version = version.bump_to_snapshot() self.assertEqual("1.2.3", str(version)) self.assertEqual("1.2.3-SNAPSHOT", str(new_version))
def test_bump_suffix(self): version = ApplicationVersion(1, 2, 3) new_version = version.bump_suffix("Alpha") self.assertEqual("1.2.3", str(version)) self.assertEqual("1.2.3-Alpha", str(new_version))
def test_bump_patch(self): version = ApplicationVersion(1, 2, 3) new_version = version.bump_patch() self.assertEqual("1.2.3", str(version)) self.assertEqual("1.2.4", str(new_version))
def test_bump_minor(self): version = ApplicationVersion(1, 2, 3) new_version = version.bump_minor() self.assertEqual("1.2.3", str(version)) self.assertEqual("1.3.0", str(new_version))