def test_commit_commit(self): with GitDir() as dir: dir.create_git_commit() commit_id = dir.create_git_commit() version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("master", 2, commit_id, False, False), version_info)
def test_commit_tag(self): with GitDir() as dir: commit_id = dir.create_git_commit() dir.create_git_tag("tagname") version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("tagname", 0, commit_id, True, False), version_info)
def test_commit_with_tracked_file(self): with GitDir() as dir: commit_id = dir.create_git_commit() dir.add_tracked_file() version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("master", 1, commit_id, False, True), version_info)
def test_commit_branch(self): with GitDir() as dir: commit_id = dir.create_git_commit() dir.create_git_branch("newbranch") version_info = versioninforeader.from_git(dir.dir) self.assertEqual( VersionInfo("newbranch", 1, commit_id, False, False), version_info)
def test_tag_with_untracked_file(self): with GitDir() as dir: commit_id = dir.create_git_commit() dir.create_git_tag("mytag") dir.add_untracked_file() version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("mytag", 0, commit_id, True, True), version_info)
def test_tag_commit_with_modified_file(self): with GitDir() as dir: filename = dir.add_tracked_file() dir.create_git_commit() dir.create_git_tag("mytag") commit_id = dir.create_git_commit() dir.modify_file(filename) version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("mytag", 1, commit_id, True, True), version_info)
def test_commit_tag_commit_branch_commit(self): with GitDir() as dir: dir.create_git_commit() dir.create_git_tag("mytag") dir.create_git_commit() dir.create_git_branch("newbranch") commit_id = dir.create_git_commit() version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("mytag", 2, commit_id, True, False), version_info)
def test_commit_branchedtaggedcommit(self): with GitDir() as dir: commit_id = dir.create_git_commit() dir.create_git_branch("newbranch") dir.create_git_commit() dir.create_git_tag("mytag") dir.switch_git_branch("master") version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("master", 1, commit_id, False, False), version_info)
def test_commit_commit_tag_rewind(self): with GitDir() as dir: dir.create_git_commit() commit_id = dir.create_git_commit() dir.create_git_commit() dir.create_git_tag("tagname") dir.checkout_git_commit(commit_id) version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("HEAD", 2, commit_id, False, False), version_info)
def test_parse_git_version_with_slashes_in_tag(self): obj = versioninforeader._parse_git_version("/heads/develop-20-gfade", False) self.assertEqual( VersionInfo("/heads/develop", 20, "fade", True, False), obj)
def test_parse_git_version_with_dashes_in_tag(self): obj = versioninforeader._parse_git_version("v1.6.3-23-20-gfade", False) self.assertEqual(VersionInfo("v1.6.3-23", 20, "fade", True, False), obj)
def test_version_string_for_tag_modified(self): self.assertEqual( "v1.5-modified", VersionInfo("v1.5", 0, "23fa", True, True).version_string)
def test_version_string_with_commits_since_tag_modified(self): self.assertEqual( "v1.5.dev2+rev23fa-modified", VersionInfo("v1.5", 2, "23fa", True, True).version_string)
def test_version_string_with_no_tag(self): self.assertEqual( "dev2+rev23fa", VersionInfo("develop", 2, "23fa", False, False).version_string)
def test_empty(self): with GitDir() as dir: version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("HEAD", 0, "0", False, False), version_info)
def test_is_dev_modified(self): self.assertTrue(VersionInfo("1.0", 0, "23fa", True, True).is_dev)
def test_is_not_dev(self): self.assertFalse(VersionInfo("1.0", 0, "23fa", True, False).is_dev)
def test_is_dev_no_commits(self): self.assertTrue(VersionInfo("1.0", 0, "23fa", False, False).is_dev)
def test_is_dev_123(self): self.assertTrue(VersionInfo("1.0", 123, "23fa", True, False).is_dev)
def test_equals(self): self.assertEqual(VersionInfo("v1.6.0", 20, "23fa", True, False), VersionInfo("v1.6.0", 20, "23fa", True, False))
def test_empty_with_tracked_file(self): with GitDir() as dir: dir.add_tracked_file() version_info = versioninforeader.from_git(dir.dir) self.assertEqual(VersionInfo("HEAD", 0, "0", False, True), version_info)
def test_version_string_for_tag(self): self.assertEqual( "v1.5", VersionInfo("v1.5", 0, "23fa", True, False).version_string)
def test_interpret_valid_tag_name_alpha_number(self): self.assertEqual( TagInterpretation(["1", "0"], "alpha2", False), VersionInfo("1.0alpha2", 0, "23fa", True, False).interpret_tag_name())
def test_version_string_with_no_tag_modified(self): self.assertEqual( "dev2+rev23fa-modified", VersionInfo("develop", 2, "23fa", False, True).version_string)
def test_parse_git_version_simple(self): obj = versioninforeader._parse_git_version("v1.6-0-g3f2a", False) self.assertEqual(VersionInfo("v1.6", 0, "3f2a", True, False), obj)
def test_not_equals_is_tag(self): self.assertNotEqual(VersionInfo("v1.6.1", 20, "23fa", True, False), VersionInfo("v1.6.1", 20, "23fa", False, False))
def test_interpret_valid_tag_name_beta(self): self.assertEqual( TagInterpretation(["1", "0"], "beta", False), VersionInfo("1.0beta", 0, "23fa", True, False).interpret_tag_name())
def test_not_equals_modified_since_commit(self): self.assertNotEqual(VersionInfo("v1.6.1", 20, "23fa", True, False), VersionInfo("v1.6.1", 20, "23fa", True, True))
def test_parse_git_version_with_commits_since_tag(self): obj = versioninforeader._parse_git_version("v1.6.3-23-g49302", False) self.assertEqual(VersionInfo("v1.6.3", 23, "49302", True, False), obj)
def test_interpret_invalid_tag_name_invalid_missing_component(self): self.assertEqual( None, VersionInfo("1,-alpha", 0, "23fa", True, False).interpret_tag_name())