本文整理汇总了Python中qisrc.test.conftest.TestGitWorkTree类的典型用法代码示例。如果您正苦于以下问题:Python TestGitWorkTree类的具体用法?Python TestGitWorkTree怎么用?Python TestGitWorkTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestGitWorkTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_switching_from_fixed_ref_to_branch_local_changes
def test_switching_from_fixed_ref_to_branch_local_changes(qisrc_action, git_server, record_messages):
""" Test Swithcing From Fixed Ref To Branch Local Changes """
git_server.create_repo("foo.git")
git_server.push_file("foo.git", "a.txt", "a")
git_server.push_tag("foo.git", "v0.1")
git_server.push_file("foo.git", "b.txt", "b")
git_server.push_tag("foo.git", "v0.2")
git_server.push_file("foo.git", "c.txt", "c")
git_server.set_fixed_ref("foo.git", "v0.1")
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = TestGit(foo_proj.path)
git.write_file("a.txt", "unstaged changes")
git_server.set_branch("foo.git", "master")
record_messages.reset()
rc = qisrc_action("sync", retcode=True)
# ERROR message must be displayed to warn user
assert rc != 0
assert record_messages.find("unstaged changes")
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/tags/v0.1")
# git repo unchanged
assert sha1 == expected
git.call("reset", "--hard")
qisrc_action("sync", retcode=True)
# if modification is revert sync must be successful
assert git.get_current_branch() == "master"
示例2: test_qisrc_checkout_with_branch_to_ref
def test_qisrc_checkout_with_branch_to_ref(qisrc_action, git_server):
""" Test QiSrc Checkout With Branch to Ref """
manifest_url = git_server.manifest_url
git_server.create_repo("foo.git")
git_server.create_repo("bar.git")
git_server.push_file("foo.git", "a.txt", "a")
git_server.push_tag("foo.git", "v0.1")
git_server.push_file("foo.git", "b.txt", "b")
git_server.push_tag("bar.git", "v0.2")
git_server.push_file("bar.git", "c.txt", "b")
qisrc_action("init", manifest_url)
git_server.switch_manifest_branch("devel")
git_server.set_fixed_ref("foo.git", "v0.1")
git_server.set_fixed_ref("bar.git", "v0.2")
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
git = TestGit(foo_proj.path)
assert git.get_current_branch() == "master"
qisrc_action("checkout", "devel")
_, sha1 = git.call("rev-parse", "HEAD", raises=False)
expected = git.get_ref_sha1("refs/tags/v0.1")
assert sha1 == expected
bar_proj = git_worktree.get_git_project("bar")
bar_git = qisrc.git.Git(bar_proj.path)
_, sha1 = bar_git.call("rev-parse", "HEAD", raises=False)
expected = bar_git.get_ref_sha1("refs/tags/v0.2")
assert sha1 == expected
示例3: test_check
def test_check(qisrc_action, git_server):
# Get a correct xml file from the server:
manifest_url = git_server.manifest_url
git_server.create_repo("foo.git")
qisrc_action("init", manifest_url)
# copy it to an other place, make a mistake, and run --check:
srv_xml = git_server.src.join("manifest", "manifest.xml")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
manifest.add_repo("doestnotexists.git", "nowhere", ["origin"])
manifest.dump()
rc = qisrc_action("check-manifest", editable_path.strpath,
retcode=True)
assert rc != 0
# running qisrc sync should still work:
qisrc_action("sync")
# this time create a correct xml and re-run --check:
git_server.create_repo("bar.git")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
manifest.dump()
qisrc_action("check-manifest", editable_path.strpath)
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("bar")
# running qisrc sync just to be sure:
qisrc_action("sync")
示例4: test_clone_new_repos
def test_clone_new_repos(qisrc_action, git_server):
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
git_server.create_repo("bar.git")
qisrc_action("sync")
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("bar")
示例5: test_check_configures_review
def test_check_configures_review(qisrc_action, git_server):
# Get a correct xml file from the server:
manifest_url = git_server.manifest_url
qisrc_action("init", manifest_url)
git_server.create_repo("foo.git")
git_server._create_repo("foo.git", review=True)
# Create a foo repo, but without code review set
foo_proj = qisrc_action.create_git_project("foo")
assert not foo_proj.review
# Edit the manifest.xml to set code review for foo
srv_xml = git_server.src.join("manifest", "manifest.xml")
manifest = qisrc.manifest.Manifest(srv_xml.strpath)
editable_path = qisrc_action.tmpdir.join("manifest.xml")
manifest.manifest_xml = editable_path.strpath
foo_repo = manifest.get_repo("foo.git")
foo_repo.remote_names = ["origin", "gerrit"]
manifest.dump()
# Run qisrc check-manifest
qisrc_action("check-manifest", editable_path.strpath)
# Code review should be now set:
git_worktree = TestGitWorkTree()
foo_proj = git_worktree.get_git_project("foo")
assert foo_proj.review
示例6: test_uses_build_deps_by_default
def test_uses_build_deps_by_default(qisrc_action, git_server):
git_server.add_qibuild_test_project("world")
git_server.add_qibuild_test_project("hello")
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
# Crete some changes in foo and world
git_server.push_file("foo.git", "foo.txt", "unrelated changes")
git_server.push_file("world.git", "world.txt", "dependency has been updated")
# Sync hello
qisrc_action.chdir("hello")
qisrc_action("sync")
qisrc_action.chdir(qisrc_action.root)
git_worktree = TestGitWorkTree()
# foo is not a dep, should not have changed:
foo_proj = git_worktree.get_git_project("foo")
foo_txt = os.path.join(foo_proj.path, "foo.txt")
assert not os.path.exists(foo_txt)
# World is a dep of hello:
world_proj = git_worktree.get_git_project("world")
world_txt = os.path.join(world_proj.path, "world.txt")
assert os.path.exists(world_txt)
示例7: test_sync_branch_devel
def test_sync_branch_devel(qisrc_action, git_server, test_git):
# This tests the case where everything goes smoothly
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
git_server.push_file("foo.git", "foo.txt", "a super change")
git_server.push_file("foo.git", "bar.txt", "a super bugfix")
git_worktree = TestGitWorkTree()
foo = git_worktree.get_git_project("foo")
test_git = TestGit(foo.path)
test_git.call("checkout", "-b", "devel")
test_git.commit_file("developing.txt", "like a boss")
git_server.push_file("foo.git", "foobar.txt", "some other change")
git_server.push_file("foo.git", "bigchange.txt", "some huge change")
qisrc_action("sync", "--rebase-devel")
test_git.call("checkout", "master")
# Check that master is fast-forwarded
bigchange_txt = os.path.join(foo.path, "bigchange.txt")
assert os.path.exists(bigchange_txt)
# Check rebase is done smoothly
test_git.call("checkout", "devel")
test_git.call("rebase", "master")
assert os.path.exists(bigchange_txt)
developing_txt = os.path.join(foo.path, "developing.txt")
assert os.path.exists(developing_txt)
示例8: test_creates_required_subdirs
def test_creates_required_subdirs(qisrc_action, git_server):
""" Test Create Required SubDirs """
git_server.create_repo("foo/bar.git")
qisrc_action("init", git_server.manifest_url)
qisrc_action("sync")
git_worktree = TestGitWorkTree()
assert git_worktree.get_git_project("foo/bar")
示例9: test_using_checkout_after_no_review
def test_using_checkout_after_no_review(qisrc_action, git_server):
git_server.create_repo("foo", review=True)
qisrc_action("init", git_server.manifest_url, "--no-review")
git_server.switch_manifest_branch("devel")
qisrc_action("checkout", "devel")
git_worktree = TestGitWorkTree()
foo = git_worktree.get_git_project("foo")
assert not foo.review
示例10: test_not_on_any_branch
def test_not_on_any_branch(qisrc_action, record_messages):
git_worktree = TestGitWorkTree()
foo = git_worktree.create_git_project("foo")
foo_git = qisrc.git.Git(foo.path)
(rc, out) = foo_git.call("log", "-1", "HEAD", "--pretty=%H", raises=False)
foo_git.checkout(out)
qisrc_action("status")
assert record_messages.find("not on any branch")
示例11: test_configure_new_repos
def test_configure_new_repos(qisrc_action, git_server):
git_server.create_repo("foo.git")
qisrc_action("init", git_server.manifest_url)
qisrc_action("sync")
git_server.create_repo("bar.git")
qisrc_action("sync", "foo") # Sync only foo, but expect to clone bar
git_worktree = TestGitWorkTree()
bar = git_worktree.get_git_project("bar")
assert bar.default_remote
示例12: test_retcode_when_skipping
def test_retcode_when_skipping(qisrc_action, git_server):
git_server.create_repo("bar")
qisrc_action("init", git_server.manifest_url)
git_worktree = TestGitWorkTree()
bar_proj = git_worktree.get_git_project("bar")
git = TestGit(bar_proj.path)
git.checkout("-b", "devel")
rc = qisrc_action("sync", retcode=True)
assert rc != 0
示例13: test_does_not_store_if_setup_fails
def test_does_not_store_if_setup_fails(git_worktree, git_server):
git_server.create_repo("foo", review=True)
manifest_url = git_server.manifest_url
worktree_syncer = qisrc.sync.WorkTreeSyncer(git_worktree)
with mock.patch("qisrc.review.setup_project") as mock_setup:
mock_setup.return_value = False
worktree_syncer.configure_manifest(manifest_url)
git_worktree2 = TestGitWorkTree()
foo = git_worktree2.get_git_project("foo")
assert foo.review is False
示例14: test_re_add_removed_by_hand
def test_re_add_removed_by_hand(qisrc_action, git_server):
manifest_url = git_server.manifest_url
setup_re_add(qisrc_action, git_server)
git_worktree = TestGitWorkTree()
c_path = git_worktree.get_git_project("c").path
qisrc_action("init", manifest_url, "--group", "mygroup")
qisys.sh.rm(c_path)
qisrc_action("init", manifest_url)
git_worktree = TestGitWorkTree()
assert len(git_worktree.git_projects) == 3
示例15: test_re_add_path_exists
def test_re_add_path_exists(qisrc_action, git_server):
setup_re_add(qisrc_action, git_server)
git_worktree = TestGitWorkTree()
c_path = git_worktree.get_git_project("c").path
qisrc_action("manifest", "default", "--group", "mygroup")
qisys.sh.rm(c_path)
qisys.sh.mkdir(c_path)
qisrc_action("manifest", "default")
git_worktree = TestGitWorkTree()
assert len(git_worktree.git_projects) == 3