示例#1
0
    def test_prepare_commit_msg_aborts_if_existing(self):
        commit_msg = "Lorem ipsum"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to(commit_msg))
示例#2
0
    def test_prepare_commit_msg_aborts_if_existing(self):
        commit_msg = "Lorem ipsum"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to(commit_msg))
示例#3
0
    def test_prepare_commit_msg_with_one_component(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John", ("setup.py", "test.py"),
                                "{component}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to("global"))
示例#4
0
    def test_prepare_commit_msg(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John",
                                template="{component}: {author}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to("unknown: John"))
示例#5
0
    def test_prepare_commit_msg(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock",
                                "John",
                                template="{component}: {author}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to("unknown: John"))
示例#6
0
    def test_prepare_commit_msg_with_one_component(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John",
                                ("setup.py", "test.py"),
                                "{component}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, equal_to("global"))
示例#7
0
    def test_prepare_commit_msg_with_many_components(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John",
                                ("setup.py", "grunt/foo.js", "docs/bar.rst"),
                                "{component}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, contains_string("global"))
            assert_that(new_commit_msg, contains_string("grunt"))
            assert_that(new_commit_msg, contains_string("docs"))
示例#8
0
    def test_prepare_commit_msg_with_many_components(self):
        commit_msg = "# this is a comment"
        mock, tmp_file = self._mock_open(commit_msg)
        with patch("kwalitee.hooks.open", mock, create=True):
            _prepare_commit_msg("mock", "John",
                                ("setup.py",
                                 "grunt/foo.js",
                                 "docs/bar.rst"),
                                "{component}")

            tmp_file.seek(0)
            new_commit_msg = "\n".join(tmp_file.readlines())

            assert_that(new_commit_msg, contains_string("global"))
            assert_that(new_commit_msg, contains_string("grunt"))
            assert_that(new_commit_msg, contains_string("docs"))