def test_init_with_uninitialized_dir(temp_empty_dir, empty_vcs_configuration): with pytest.raises(re.RepositorySystemError) as exc: hr.HgRepo(temp_empty_dir, empty_vcs_configuration) assert str(exc.value) == \ "The current directory {} is not a Hg repository".format( temp_empty_dir)
def test_pre_start_release_start_from_different_branch( temp_hg_dir, empty_vcs_configuration): hg_dir = temp_hg_dir repo = hr.HgRepo(hg_dir, empty_vcs_configuration) hg_repo_add_branch(hg_dir, "other") repo.pre_start_release() assert repo.get_current_branch() == repo.DEFAULT_BRANCH
def test_finish_should_recover_start_branch( hg_other_branch, other_branch_vcs_configuration): hg_repo_add_branch(hg_other_branch, "third") repo = hr.HgRepo(hg_other_branch, other_branch_vcs_configuration) repo.pre_start_release() repo.start_release() repo.finish_release() assert repo.get_current_branch() == "third"
def test_finish_release_without_changes( hg_other_branch, other_branch_vcs_configuration): repo = hr.HgRepo(hg_other_branch, other_branch_vcs_configuration) repo.pre_start_release() repo.start_release() repo.finish_release() assert repo.get_current_branch() == repo.DEFAULT_BRANCH assert 'b' not in repo.get_tags()
def test_start_summary(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) repo.pre_start_release() assert repo.get_summary() == { "branch": "default", "commit": "(clean)", "update": "(current)" }
def test_pre_start_release_should_use_other_branch( temp_hg_dir, other_branch_vcs_configuration): hg_dir = temp_hg_dir repo = hr.HgRepo(hg_dir, other_branch_vcs_configuration) hg_repo_add_branch(hg_dir, "other") repo.pre_start_release() hg_repo_change_branch(hg_dir, repo.DEFAULT_BRANCH) repo.pre_start_release() assert repo.get_current_branch() == "other"
def test_pre_start_release_in_unclean_state( temp_hg_dir, empty_vcs_configuration): hg_dir = temp_hg_dir with open(os.path.join(hg_dir, "README.md"), "w") as f: f.writelines(["Uncommitted lines"]) repo = hr.HgRepo(hg_dir, empty_vcs_configuration) with pytest.raises(re.RepositoryStatusError): repo.pre_start_release() assert repo.get_current_branch() == repo.DEFAULT_BRANCH
def test_finish_release_custom_tag_cannot_be_a_number(temp_hg_dir): release_name = "1.0" commit_message = "A commit message" tag = "12234" config = vc.VCSConfiguration('hg', {'tag': tag}, global_variables={}, special_variables={ 'new_version': release_name}, commit_message=commit_message) with pytest.raises(re.RepositoryConfigurationError): hr.HgRepo(temp_hg_dir, config)
def ready_to_finish_repo(temp_hg_dir, **kwargs): release_name = "1.0" commit_message = "A commit message" config = vc.VCSConfiguration( 'git', kwargs, global_variables={}, special_variables={'new_version': release_name}, commit_message=commit_message ) repo = hr.HgRepo(temp_hg_dir, config) repo.pre_start_release() repo.start_release() hg_repo_add_file(temp_hg_dir, "version.txt", release_name + "\n") return repo
def test_start_release_should_be_in_defined_branch( hg_other_branch, other_branch_vcs_configuration): repo = hr.HgRepo(hg_other_branch, other_branch_vcs_configuration) repo.pre_start_release() repo.start_release() assert repo.get_current_branch() == "other"
def test_pre_start_release(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) repo.pre_start_release() assert repo.get_current_branch() == repo.DEFAULT_BRANCH
def test_get_tags(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) assert repo.get_tags() == 'tip'
def test_get_current_branch(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) assert repo.get_current_branch() == repo.DEFAULT_BRANCH
def test_init(temp_empty_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_empty_hg_dir, empty_vcs_configuration) assert repo.working_path == temp_empty_hg_dir
def test_get_branches(hg_other_branch, empty_vcs_configuration): repo = hr.HgRepo(hg_other_branch, empty_vcs_configuration) assert {"default", "other"} == repo.get_branches()
def test_tag(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) repo.tag("just_a_tag") assert "just_a_tag" in repo.get_tags()
def test_get_info(temp_hg_dir, empty_vcs_configuration): repo = hr.HgRepo(temp_hg_dir, empty_vcs_configuration) assert repo.get_info() == [ ("Commit message", "Version updated a -> b"), ]