def test_main(testpkg, monkeypatch):
    # Fake the "upstream/1.0" tag that `gbp import-orig` would've created:
    git('tag', '-a', 'upstream/1.0', '-m', 'Upstream version 1.0')
    recorder = CallRecorder()
    monkeypatch.setattr('subprocess.check_call', recorder)
    nv = NewVersion(['rhcephpkg'])
    nv.main()
def test_import_orig(monkeypatch):
    recorder = CallRecorder()
    monkeypatch.setattr('subprocess.check_call', recorder)
    nv = NewVersion(['rhcephpkg'])
    nv.import_orig()
    expected = ['gbp', 'import-orig', '--no-interactive', '--uscan']
    assert recorder.args == expected
def test_run_dch(testpkg, monkeypatch):
    recorder = CallRecorder()
    monkeypatch.setattr('subprocess.check_call', recorder)
    nv = NewVersion(['rhcephpkg'])
    nv.run_dch('1.0', 'rhbz#123')
    text = 'Imported Upstream version 1.0 (rhbz#123)'
    expected = ['dch', '-D', 'xenial', '-v', '1.0-2redhat1', text]
    assert recorder.args == expected
def test_import_orig_tarball(monkeypatch):
    recorder = CallRecorder()
    monkeypatch.setattr('subprocess.check_call', recorder)
    nv = NewVersion(['rhcephpkg'])
    tarball = 'testpkg_1.0.orig.tar.gz'
    nv.import_orig(tarball)
    expected = ['gbp', 'import-orig', '--no-interactive', tarball]
    assert recorder.args == expected
示例#5
0
 def test_checkout(self, testpkg, monkeypatch):
     """ Test the happy path for checking out a branch """
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     argv = ['checkout-from-patches', 'ceph-2-rhel-patches']
     cfp = CheckoutFromPatches(argv)
     cfp.main()
     assert recorder.args == ['git', 'checkout', 'ceph-2-ubuntu']
示例#6
0
 def test_remote_and_local_branches_present(self, testpkg, monkeypatch):
     refsdir = testpkg.join('.git').join('refs')
     refsdir.mkdir('remotes').mkdir('origin').ensure('pristine-tar',
                                                     file=True)
     refsdir.join('heads').ensure('pristine-tar', file=True)
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.call', recorder)
     util.setup_pristine_tar_branch()
     assert recorder.called == 0
 def test_force_on_patch_queue_branch(self, testpkg, monkeypatch):
     # set current_branch() to a patch-queue branch:
     git('checkout', 'patch-queue/ceph-2-ubuntu')
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     mergep = MergePatches([])
     mergep._run(force=True)
     # Verify that we run the "git reset" command here.
     expected = ['git', 'reset', '--hard', 'patches/ceph-2-rhel-patches']
     assert recorder.args == expected
 def test_on_patch_queue_branch(self, testpkg, monkeypatch):
     # set our current branch to be a patch-queue branch:
     git('checkout', 'patch-queue/ceph-2-ubuntu')
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     mergep = MergePatches([])
     mergep._run()
     # Verify that we run the "git merge" command here.
     expected = ['git', 'pull', '--ff-only', 'patches/ceph-2-rhel-patches']
     assert recorder.args == expected
示例#9
0
 def test_source(self, monkeypatch):
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     localbuild = Source([])
     localbuild._run()
     expected = [
         'gbp', 'buildpackage', '--git-tag', '--git-retag', '-S', '-us',
         '-uc'
     ]
     assert recorder.args == expected
示例#10
0
 def test_remote_branch_present(self, testpkg, monkeypatch):
     remotesdir = testpkg.join('.git').join('refs').mkdir('remotes')
     remotesdir.mkdir('origin').ensure('pristine-tar', file=True)
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.call', recorder)
     util.setup_pristine_tar_branch()
     expected = [
         'git', 'branch', '--track', 'pristine-tar', 'origin/pristine-tar'
     ]
     assert recorder.args == expected
示例#11
0
 def test_localbuild(self, testpkg, args, expected, monkeypatch):
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     monkeypatch.setattr('rhcephpkg.Localbuild._get_j_arg',
                         lambda *a: '-j2')
     localbuild = Localbuild(args)
     localbuild.main()
     assert recorder.args == [
         'gbp', 'buildpackage', expected, '--git-arch=amd64',
         '--git-verbose', '--git-pbuilder', '-j2', '-us', '-uc'
     ]
示例#12
0
 def test_ensure_patch_queue_branch(self, testpkg, monkeypatch):
     remotesdir = testpkg.join('.git').join('refs').mkdir('remotes')
     remotesdir.mkdir('origin').ensure('patch-queue/ceph-2-ubuntu',
                                       file=True)
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.call', recorder)
     util.ensure_patch_queue_branch()
     expected = [
         'git', 'branch', '--force', '--track', 'patch-queue/ceph-2-ubuntu',
         'origin/patch-queue/ceph-2-ubuntu'
     ]
     assert recorder.args == expected
示例#13
0
 def test_force_on_debian_branch(self, testpkg, monkeypatch):
     # set current_branch() to a debian branch:
     git('checkout', 'ceph-2-ubuntu')
     recorder = CallRecorder()
     monkeypatch.setattr('subprocess.check_call', recorder)
     localbuild = MergePatches([])
     localbuild._run(force=True)
     # Verify that we run the "git push" command here.
     expected = [
         'git', 'push', '.',
         '+patches/ceph-2-rhel-patches:patch-queue/ceph-2-ubuntu'
     ]
     assert recorder.args == expected
示例#14
0
 def test_main(self, monkeypatch):
     recorder = CallRecorder()
     monkeypatch.setattr(Hello, '_run', recorder)
     hello = Hello([])
     hello.main()
     assert recorder.called