##// END OF EJS Templates
feat(task-for-automatic-pr-merge): added f-ty to support pull request auto merge for EE. Fixes: RCCE-67
feat(task-for-automatic-pr-merge): added f-ty to support pull request auto merge for EE. Fixes: RCCE-67

File last commit:

r5608:6d33e504 default
r5657:027566d5 default
Show More
test_branches.py
141 lines | 5.2 KiB | text/x-python | PythonLexer
copyrights: updated for 2023
r5088 # Copyright (C) 2010-2023 RhodeCode GmbH
project: added all source files and assets
r1 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import datetime
import pytest
from rhodecode.lib.vcs.nodes import FileNode
tests: use gunicorn for testing. This is close to production testing...
r2453 from rhodecode.tests.vcs.conftest import BackendTestMixin
project: added all source files and assets
r1
tests: use gunicorn for testing. This is close to production testing...
r2453 @pytest.mark.usefixtures("vcs_repository_support")
project: added all source files and assets
r1 class TestBranches(BackendTestMixin):
def test_empty_repository_has_no_branches(self, vcsbackend):
empty_repo = vcsbackend.create_repo()
assert empty_repo.branches == {}
def test_branches_all(self, vcsbackend):
branch_count = {
tests(fix): fixed git tests for new head branches
r5218 "git": 1,
"hg": 1,
"svn": 0,
project: added all source files and assets
r1 }
assert len(self.repo.branches_all) == branch_count[vcsbackend.alias]
def test_closed_branches(self):
assert len(self.repo.branches_closed) == 0
tests: fixed tests after removing hardcoded timezone in tests.
r1351 def test_simple(self, local_dt_to_utc):
project: added all source files and assets
r1 tip = self.repo.get_commit()
tests(fix): fixed git tests for new head branches
r5218 assert tip.message == "Changes..."
tests: fixed tests after removing hardcoded timezone in tests.
r1351 assert tip.date == local_dt_to_utc(datetime.datetime(2010, 1, 1, 21))
project: added all source files and assets
r1
@pytest.mark.backends("git", "hg")
def test_new_branch(self):
# This check must not be removed to ensure the 'branches' LazyProperty
# gets hit *before* the new 'foobar' branch got created:
tests(fix): fixed git tests for new head branches
r5218 assert "foobar" not in self.repo.branches
self.imc.add(FileNode(b"docs/index.txt", content=b"Documentation\n"))
project: added all source files and assets
r1 foobar_tip = self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 message="New branch: foobar",
author="joe <joe@rhodecode.com>",
branch="foobar",
project: added all source files and assets
r1 )
tests(fix): fixed git tests for new head branches
r5218 assert "foobar" in self.repo.branches
assert foobar_tip.branch == "foobar"
project: added all source files and assets
r1
@pytest.mark.backends("git", "hg")
def test_new_head(self):
tip = self.repo.get_commit()
tests(fix): fixed git tests for new head branches
r5218
tests: fixed all tests for python3 BIG changes
r5087 self.imc.add(
tests(fix): fixed git tests for new head branches
r5218 FileNode(b"docs/index.txt", content=b"Documentation\n")
tests: fixed all tests for python3 BIG changes
r5087 )
project: added all source files and assets
r1 foobar_tip = self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 message="New branch: foobar",
author="joe <joe@rhodecode.com>",
branch="foobar",
project: added all source files and assets
r1 parents=[tip],
)
tests(fix): fixed git tests for new head branches
r5218 self.imc.change(
FileNode(b"docs/index.txt", content=b"Documentation\nand more...\n")
)
assert foobar_tip.branch == "foobar"
project: added all source files and assets
r1 newtip = self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 message="At foobar_tip branch",
author="joe <joe@rhodecode.com>",
project: added all source files and assets
r1 branch=foobar_tip.branch,
parents=[foobar_tip],
)
newest_tip = self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 message=f"Merged with {foobar_tip.raw_id}",
author="joe <joe@rhodecode.com>",
project: added all source files and assets
r1 branch=self.backend_class.DEFAULT_BRANCH_NAME,
tests(fix): fixed git tests for new head branches
r5218 parents=[tip, newtip],
project: added all source files and assets
r1 )
tests(fix): fixed git tests for new head branches
r5218 assert newest_tip.branch == self.backend_class.DEFAULT_BRANCH_NAME
project: added all source files and assets
r1
@pytest.mark.backends("git", "hg")
def test_branch_with_slash_in_name(self):
tests(fix): fixed git tests for new head branches
r5218 self.imc.add(FileNode(b"extrafile", content=b"Some data\n"))
project: added all source files and assets
r1 self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123"
)
assert "issue/123" in self.repo.branches
project: added all source files and assets
r1
@pytest.mark.backends("git", "hg")
def test_branch_with_slash_in_name_and_similar_without(self):
tests(fix): fixed git tests for new head branches
r5218 self.imc.add(FileNode(b"extrafile", content=b"Some data\n"))
project: added all source files and assets
r1 self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123"
)
self.imc.add(FileNode(b"extrafile II", content=b"Some data\n"))
project: added all source files and assets
r1 self.imc.commit(
tests(fix): fixed git tests for new head branches
r5218 "Branch without a slash...", author="joe <joe@rhodecode.com>", branch="123"
)
assert "issue/123" in self.repo.branches
assert "123" in self.repo.branches
project: added all source files and assets
r1
tests: fixed tests after removing hardcoded timezone in tests.
r1351 class TestSvnBranches(object):
project: added all source files and assets
r1 def test_empty_repository_has_no_tags_and_branches(self, vcsbackend_svn):
empty_repo = vcsbackend_svn.create_repo()
assert empty_repo.branches == {}
assert empty_repo.tags == {}
def test_missing_structure_has_no_tags_and_branches(self, vcsbackend_svn):
repo = vcsbackend_svn.create_repo(number_of_commits=1)
assert repo.branches == {}
assert repo.tags == {}
def test_discovers_ordered_branches(self, vcsbackend_svn):
tests(fix): fixed git tests for new head branches
r5218 repo = vcsbackend_svn["svn-simple-layout"]
project: added all source files and assets
r1 expected_branches = [
tests(fix): fixed git tests for new head branches
r5218 "branches/add-docs",
"branches/argparse",
"trunk",
project: added all source files and assets
r1 ]
tests: fixed all tests for python3 BIG changes
r5087 assert list(repo.branches.keys()) == expected_branches
project: added all source files and assets
r1
def test_discovers_ordered_tags(self, vcsbackend_svn):
tests(fix): fixed git tests for new head branches
r5218 repo = vcsbackend_svn["svn-simple-layout"]
expected_tags = ["tags/v0.1", "tags/v0.2", "tags/v0.3", "tags/v0.5"]
tests: fixed all tests for python3 BIG changes
r5087 assert list(repo.tags.keys()) == expected_tags