diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-10-27 19:19:09 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-10-27 19:27:05 +0200 |
commit | fe987441fdbc7f2dc57372df93e4f07c38eb1e23 (patch) | |
tree | d662e6fc70556691d65a5d716933c15b35422b5e /tests | |
parent | 7219d00ffa65e87f2545aaf07eb1809d3b388f6a (diff) | |
download | git-buildpackage-fe987441fdbc7f2dc57372df93e4f07c38eb1e23.tar.gz git-buildpackage-fe987441fdbc7f2dc57372df93e4f07c38eb1e23.tar.bz2 git-buildpackage-fe987441fdbc7f2dc57372df93e4f07c38eb1e23.zip |
Add tests for non bare clones
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_GitRepository.py | 76 |
1 files changed, 64 insertions, 12 deletions
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index 2202e5cb..3f195455 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -9,6 +9,8 @@ repo_dir = os.path.abspath( os.path.join(os.path.curdir, 'gbp_%s_test_repo' % __name__)) clone_dir = os.path.abspath( os.path.join(os.path.curdir, 'gbp_%s_test_clone' % __name__)) +mirror_clone_dir = os.path.abspath( + os.path.join(os.path.curdir, 'gbp_%s_test_mirror_clone' % __name__)) def test_create(): @@ -225,12 +227,13 @@ def test_list_files(): """ -def test_clone(): +def test_mirror_clone(): """ - Clone a repository + Mirror a repository Methods tested: - L{gbp.git.GitRepository.clone} + - L{gbp.git.GitRepository.is_empty} - L{gbp.git.GitRepository.set_branch} - L{gbp.git.GitRepository.has_branch} - L{gbp.git.GitRepository.branch} @@ -238,18 +241,53 @@ def test_clone(): >>> import gbp.git >>> repo = gbp.git.GitRepository(repo_dir) >>> repo.set_branch('master') - >>> clone = gbp.git.GitRepository.clone(clone_dir, repo.path, mirror=True) - >>> clone.branch + >>> mirror = gbp.git.GitRepository.clone(mirror_clone_dir, repo.path, mirror=True) + >>> mirror.is_empty() + False + >>> mirror.branch 'master' - >>> clone.has_branch('foo') + >>> mirror.has_branch('foo') True - >>> clone.has_branch('bar') + >>> mirror.has_branch('bar') False - >>> clone.set_branch('foo') - >>> clone.branch + >>> mirror.set_branch('foo') + >>> mirror.branch 'foo' """ +def test_clone(): + """ + Clone a repository + + Methods tested: + - L{gbp.git.GitRepository.clone} + - L{gbp.git.GitRepository.is_empty} + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.branch} + - L{gbp.git.GitRepository.get_remote_branches} + - L{gbp.git.GitRepository.get_local_branches} + + >>> import gbp.git + >>> repo = gbp.git.GitRepository(repo_dir) + >>> repo.set_branch('master') + >>> clone = gbp.git.GitRepository.clone(clone_dir, repo.path) + >>> clone.is_empty() + False + >>> clone.branch + 'master' + >>> clone.get_remote_branches() + ['origin/HEAD', 'origin/foo', 'origin/master'] + >>> clone.get_local_branches() + ['master'] + >>> clone.get_merge_branch('master') + 'origin/master' + >>> clone.create_branch('foo', 'origin/foo') + >>> clone.get_merge_branch('foo') + 'origin/foo' + >>> clone.get_local_branches() + ['foo', 'master'] + """ + def test_merge(): """ Merge a branch @@ -264,15 +302,29 @@ def test_merge(): >>> repo.merge('foo') """ +def test_pull(): + """ + Pull from a remote repository + + Methods tested: + - L{gbp.git.GitRepository.set_branch} + - L{gbp.git.GitRepository.pull} + + >>> import gbp.git, os + >>> d = os.path.join(clone_dir, 'gbp_%s_test_repo' % __name__) + >>> clone = gbp.git.GitRepository(d) + >>> clone.set_branch('master') + >>> clone.pull() + """ + def test_teardown(): """ Perform the teardown >>> import shutil, os - >>> if not os.getenv("GBP_TESTS_NOCLEAN") and repo_dir: \ - shutil.rmtree(repo_dir) - >>> if not os.getenv("GBP_TESTS_NOCLEAN") and clone_dir: \ - shutil.rmtree(clone_dir) + >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(repo_dir) + >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(mirror_clone_dir) + >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(clone_dir) """ # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |