Пример #1
0
 def test_bz_present(self, testpkg, monkeypatch, capsys):
     monkeypatch.setattr('rhcephpkg.gitbz.Bugzilla', FakeBugzilla)
     git('commit', '--amend', '-m', 'Resolves: rhbz#123')
     gitbz = Gitbz([])
     gitbz.main()
     out, _ = capsys.readouterr()
     assert out == "rhbz#123: ceph-2.y+\n"
Пример #2
0
 def test_bad_branch(self, testpkg, monkeypatch):
     git('branch', '-m', 'private-kdreyer-ceph-2-ubuntu')
     gitbz = Gitbz([])
     with pytest.raises(SystemExit) as e:
         gitbz.main()
     assert str(e.value) == ('could not parse debian branch '
                             '"private-kdreyer-ceph-2-ubuntu".')
Пример #3
0
 def test_not_logged_in(self, testpkg, monkeypatch):
     monkeypatch.setattr('rhcephpkg.gitbz.Bugzilla', FakeAnonymousBugzilla)
     git('commit', '--amend', '-m', 'Resolves: rhbz#123')
     gitbz = Gitbz([])
     with pytest.raises(SystemExit) as e:
         gitbz.main()
     assert str(e.value) == 'Not logged into BZ'
Пример #4
0
 def test_bz_missing(self, testpkg, monkeypatch, capsys, branch, expected):
     monkeypatch.setattr('rhcephpkg.gitbz.Bugzilla', FakeBugzilla)
     git('commit', '--amend', '-m', 'Resolves: rhbz#123')
     git('branch', '-m', branch)
     gitbz = Gitbz([])
     with pytest.raises(SystemExit):
         gitbz.main()
     out, _ = capsys.readouterr()
     assert out == expected
Пример #5
0
    def test_amended_patch(self, testpkg, capsys):
        p = Patch([])
        p.main()
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        testpkg.join('foobar.py').write('#!/usr/bin/python')
        git('commit', 'foobar.py', '--amend', '--reset-author', '--no-edit')
        p.main()
        changelog_file = testpkg.join('debian').join('changelog')
        expected = """
testpkg (1.0.0-4redhat1) stable; urgency=medium

  * Modified debian/patches/0001-add-foobar-script.patch (rhbz#123)

""".lstrip("\n")
        result = changelog_file.read()
        assert result.startswith(expected)
Пример #6
0
    def test_amended_patch(self, testpkg, capsys):
        p = Patch([])
        p.main()
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        testpkg.join('foobar.py').write('#!/usr/bin/python')
        git('commit', 'foobar.py', '--amend', '--reset-author', '--no-edit')
        p.main()
        changelog_file = testpkg.join('debian').join('changelog')
        expected = """
testpkg (1.0.0-4redhat1) stable; urgency=medium

  * Modified debian/patches/0001-add-foobar-script.patch (rhbz#123)

""".lstrip("\n")
        result = changelog_file.read()
        assert result.startswith(expected)
Пример #7
0
 def test_rules(self, testpkg):
     """ Verify that we update the debian/rules file correctly. """
     rules_file = testpkg.join('debian').join('rules')
     sha = git('rev-parse', 'patch-queue/ceph-2-ubuntu')
     expected = 'COMMIT=%s' % sha
     assert expected not in rules_file.read()
     p = Patch([])
     p.main()
     assert expected in rules_file.read()
Пример #8
0
 def test_rules(self, testpkg):
     """ Verify that we update the debian/rules file correctly. """
     rules_file = testpkg.join('debian').join('rules')
     sha = git('rev-parse', 'patch-queue/ceph-2-ubuntu')
     expected = 'COMMIT=%s' % sha
     assert expected not in rules_file.read()
     p = Patch([])
     p.main()
     assert expected in rules_file.read()
Пример #9
0
    def testpkg(self, testpkg):
        """
        Override the testpkg fixture with some additional content.

        TODO: just move this all to the main testpkg fixture? What's the
        performance impact? (Note the checked-out branch behavior at the end is
        different...)
        """
        # Add a "foobar" commit to the patch-queue branch.
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        testpkg.join('foobar.py').ensure(file=True)
        git('add', 'foobar.py')
        git('commit', 'foobar.py', '-m', 'add foobar script',
            '-m', 'Resolves: rhbz#123')
        # Note we're not on the debian branch any more, so we implicitly test
        # that path.
        return testpkg
Пример #10
0
    def testpkg(self, testpkg):
        """
        Override the testpkg fixture with some additional content.

        TODO: just move this all to the main testpkg fixture? What's the
        performance impact? (Note the checked-out branch behavior at the end is
        different...)
        """
        # Add a "foobar" commit to the patch-queue branch.
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        testpkg.join('foobar.py').ensure(file=True)
        git('add', 'foobar.py')
        git('commit', 'foobar.py', '-m', 'add foobar script', '-m',
            'Resolves: rhbz#123')
        # Note we're not on the debian branch any more, so we implicitly test
        # that path.
        return testpkg
Пример #11
0
def testpkg(tmpdir, monkeypatch):
    """ Set up a minimal testpkg Git repository and chdir into it. """
    fdir = py.path.local(FIXTURES_DIR)
    dest = tmpdir.mkdir('testpkg')
    fdir.join('testpkg').copy(dest)
    monkeypatch.chdir(dest)
    git('init', '-q')
    git('config', 'user.name', 'Test User')
    git('config', 'user.email', '*****@*****.**')
    git('add', '*')
    git('commit', '-q', '-m', 'initial import')
    git('branch', '-m', 'ceph-2-ubuntu')
    git('branch', 'patch-queue/ceph-2-ubuntu')
    return dest
Пример #12
0
    def test_delete_earlier_patch(self, testpkg, capsys):
        """
        Verify behavior when we delete an earlier .patch file and the others
        are renamed.
        """
        p = Patch([])
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        # Add a second "baz" commit:
        testpkg.join('baz.py').write('#!/usr/bin/python')
        git('add', 'baz.py')
        git('commit', 'baz.py', '-m', 'add baz script', '-m',
            'Resolves: rhbz#456')
        testpkg.join('baz.py').ensure(file=True)
        # Commit both "foobar" and "baz" patches to the dist-git branch:
        p.main()
        # Delete both the "foobar" and "baz" patches from our patch-queue:
        git('checkout', 'patch-queue/ceph-2-ubuntu')
        git('reset', '--hard', 'HEAD~2')
        # But really keep the "baz" patch:
        git('cherry-pick', 'HEAD@{4}')  # this is too fragile :(
        p.main()
        changelog_file = testpkg.join('debian').join('changelog')
        # Verify we do not mention "baz" here, since it was simply
        # rebased/renumbered:
        expected = """
testpkg (1.0.0-4redhat1) stable; urgency=medium

  * Deleted debian/patches/0001-add-foobar-script.patch (rhbz#123)

""".lstrip("\n")
        result = changelog_file.read()
        assert result.startswith(expected)