Show More
@@ -1,4 +1,3 b'' | |||||
1 |
|
||||
2 |
|
|
1 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
3 | # |
|
2 | # | |
4 | # This program is free software: you can redistribute it and/or modify |
|
3 | # This program is free software: you can redistribute it and/or modify | |
@@ -27,16 +26,15 b' from rhodecode.tests.vcs.conftest import' | |||||
27 |
|
26 | |||
28 | @pytest.mark.usefixtures("vcs_repository_support") |
|
27 | @pytest.mark.usefixtures("vcs_repository_support") | |
29 | class TestBranches(BackendTestMixin): |
|
28 | class TestBranches(BackendTestMixin): | |
30 |
|
||||
31 | def test_empty_repository_has_no_branches(self, vcsbackend): |
|
29 | def test_empty_repository_has_no_branches(self, vcsbackend): | |
32 | empty_repo = vcsbackend.create_repo() |
|
30 | empty_repo = vcsbackend.create_repo() | |
33 | assert empty_repo.branches == {} |
|
31 | assert empty_repo.branches == {} | |
34 |
|
32 | |||
35 | def test_branches_all(self, vcsbackend): |
|
33 | def test_branches_all(self, vcsbackend): | |
36 | branch_count = { |
|
34 | branch_count = { | |
37 |
|
|
35 | "git": 1, | |
38 |
|
|
36 | "hg": 1, | |
39 |
|
|
37 | "svn": 0, | |
40 | } |
|
38 | } | |
41 | assert len(self.repo.branches_all) == branch_count[vcsbackend.alias] |
|
39 | assert len(self.repo.branches_all) == branch_count[vcsbackend.alias] | |
42 |
|
40 | |||
@@ -45,82 +43,79 b' class TestBranches(BackendTestMixin):' | |||||
45 |
|
43 | |||
46 | def test_simple(self, local_dt_to_utc): |
|
44 | def test_simple(self, local_dt_to_utc): | |
47 | tip = self.repo.get_commit() |
|
45 | tip = self.repo.get_commit() | |
48 |
assert tip.message == |
|
46 | assert tip.message == "Changes..." | |
49 | assert tip.date == local_dt_to_utc(datetime.datetime(2010, 1, 1, 21)) |
|
47 | assert tip.date == local_dt_to_utc(datetime.datetime(2010, 1, 1, 21)) | |
50 |
|
48 | |||
51 | @pytest.mark.backends("git", "hg") |
|
49 | @pytest.mark.backends("git", "hg") | |
52 | def test_new_branch(self): |
|
50 | def test_new_branch(self): | |
53 | # This check must not be removed to ensure the 'branches' LazyProperty |
|
51 | # This check must not be removed to ensure the 'branches' LazyProperty | |
54 | # gets hit *before* the new 'foobar' branch got created: |
|
52 | # gets hit *before* the new 'foobar' branch got created: | |
55 |
assert |
|
53 | assert "foobar" not in self.repo.branches | |
56 | self.imc.add( |
|
54 | self.imc.add(FileNode(b"docs/index.txt", content=b"Documentation\n")) | |
57 | FileNode(b'docs/index.txt', content=b'Documentation\n') |
|
|||
58 | ) |
|
|||
59 | foobar_tip = self.imc.commit( |
|
55 | foobar_tip = self.imc.commit( | |
60 |
message= |
|
56 | message="New branch: foobar", | |
61 |
author= |
|
57 | author="joe <joe@rhodecode.com>", | |
62 |
branch= |
|
58 | branch="foobar", | |
63 | ) |
|
59 | ) | |
64 |
assert |
|
60 | assert "foobar" in self.repo.branches | |
65 |
assert foobar_tip.branch == |
|
61 | assert foobar_tip.branch == "foobar" | |
66 |
|
62 | |||
67 | @pytest.mark.backends("git", "hg") |
|
63 | @pytest.mark.backends("git", "hg") | |
68 | def test_new_head(self): |
|
64 | def test_new_head(self): | |
69 | tip = self.repo.get_commit() |
|
65 | tip = self.repo.get_commit() | |
|
66 | ||||
70 | self.imc.add( |
|
67 | self.imc.add( | |
71 |
FileNode(b |
|
68 | FileNode(b"docs/index.txt", content=b"Documentation\n") | |
72 | content=b'Documentation\n') |
|
|||
73 | ) |
|
69 | ) | |
74 | foobar_tip = self.imc.commit( |
|
70 | foobar_tip = self.imc.commit( | |
75 |
message= |
|
71 | message="New branch: foobar", | |
76 |
author= |
|
72 | author="joe <joe@rhodecode.com>", | |
77 |
branch= |
|
73 | branch="foobar", | |
78 | parents=[tip], |
|
74 | parents=[tip], | |
79 | ) |
|
75 | ) | |
80 |
self.imc.change( |
|
76 | self.imc.change( | |
81 | b'docs/index.txt', |
|
77 | FileNode(b"docs/index.txt", content=b"Documentation\nand more...\n") | |
82 | content=b'Documentation\nand more...\n')) |
|
78 | ) | |
|
79 | assert foobar_tip.branch == "foobar" | |||
83 | newtip = self.imc.commit( |
|
80 | newtip = self.imc.commit( | |
84 |
message= |
|
81 | message="At foobar_tip branch", | |
85 |
author= |
|
82 | author="joe <joe@rhodecode.com>", | |
86 | branch=foobar_tip.branch, |
|
83 | branch=foobar_tip.branch, | |
87 | parents=[foobar_tip], |
|
84 | parents=[foobar_tip], | |
88 | ) |
|
85 | ) | |
89 |
|
86 | |||
90 | newest_tip = self.imc.commit( |
|
87 | newest_tip = self.imc.commit( | |
91 |
message= |
|
88 | message=f"Merged with {foobar_tip.raw_id}", | |
92 |
author= |
|
89 | author="joe <joe@rhodecode.com>", | |
93 | branch=self.backend_class.DEFAULT_BRANCH_NAME, |
|
90 | branch=self.backend_class.DEFAULT_BRANCH_NAME, | |
94 |
parents=[ |
|
91 | parents=[tip, newtip], | |
95 | ) |
|
92 | ) | |
96 |
|
93 | |||
97 |
assert newest_tip.branch == |
|
94 | assert newest_tip.branch == self.backend_class.DEFAULT_BRANCH_NAME | |
98 | self.backend_class.DEFAULT_BRANCH_NAME |
|
|||
99 |
|
95 | |||
100 | @pytest.mark.backends("git", "hg") |
|
96 | @pytest.mark.backends("git", "hg") | |
101 | def test_branch_with_slash_in_name(self): |
|
97 | def test_branch_with_slash_in_name(self): | |
102 |
self.imc.add(FileNode(b |
|
98 | self.imc.add(FileNode(b"extrafile", content=b"Some data\n")) | |
103 | self.imc.commit( |
|
99 | self.imc.commit( | |
104 |
|
|
100 | "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123" | |
105 | branch='issue/123') |
|
101 | ) | |
106 |
assert |
|
102 | assert "issue/123" in self.repo.branches | |
107 |
|
103 | |||
108 | @pytest.mark.backends("git", "hg") |
|
104 | @pytest.mark.backends("git", "hg") | |
109 | def test_branch_with_slash_in_name_and_similar_without(self): |
|
105 | def test_branch_with_slash_in_name_and_similar_without(self): | |
110 |
self.imc.add(FileNode(b |
|
106 | self.imc.add(FileNode(b"extrafile", content=b"Some data\n")) | |
111 | self.imc.commit( |
|
107 | self.imc.commit( | |
112 |
|
|
108 | "Branch with a slash!", author="joe <joe@rhodecode.com>", branch="issue/123" | |
113 | branch='issue/123') |
|
109 | ) | |
114 |
self.imc.add(FileNode(b |
|
110 | self.imc.add(FileNode(b"extrafile II", content=b"Some data\n")) | |
115 | self.imc.commit( |
|
111 | self.imc.commit( | |
116 |
|
|
112 | "Branch without a slash...", author="joe <joe@rhodecode.com>", branch="123" | |
117 | branch='123') |
|
113 | ) | |
118 |
assert |
|
114 | assert "issue/123" in self.repo.branches | |
119 |
assert |
|
115 | assert "123" in self.repo.branches | |
120 |
|
116 | |||
121 |
|
117 | |||
122 | class TestSvnBranches(object): |
|
118 | class TestSvnBranches(object): | |
123 |
|
||||
124 | def test_empty_repository_has_no_tags_and_branches(self, vcsbackend_svn): |
|
119 | def test_empty_repository_has_no_tags_and_branches(self, vcsbackend_svn): | |
125 | empty_repo = vcsbackend_svn.create_repo() |
|
120 | empty_repo = vcsbackend_svn.create_repo() | |
126 | assert empty_repo.branches == {} |
|
121 | assert empty_repo.branches == {} | |
@@ -132,16 +127,15 b' class TestSvnBranches(object):' | |||||
132 | assert repo.tags == {} |
|
127 | assert repo.tags == {} | |
133 |
|
128 | |||
134 | def test_discovers_ordered_branches(self, vcsbackend_svn): |
|
129 | def test_discovers_ordered_branches(self, vcsbackend_svn): | |
135 |
repo = vcsbackend_svn[ |
|
130 | repo = vcsbackend_svn["svn-simple-layout"] | |
136 | expected_branches = [ |
|
131 | expected_branches = [ | |
137 |
|
|
132 | "branches/add-docs", | |
138 |
|
|
133 | "branches/argparse", | |
139 |
|
|
134 | "trunk", | |
140 | ] |
|
135 | ] | |
141 | assert list(repo.branches.keys()) == expected_branches |
|
136 | assert list(repo.branches.keys()) == expected_branches | |
142 |
|
137 | |||
143 | def test_discovers_ordered_tags(self, vcsbackend_svn): |
|
138 | def test_discovers_ordered_tags(self, vcsbackend_svn): | |
144 |
repo = vcsbackend_svn[ |
|
139 | repo = vcsbackend_svn["svn-simple-layout"] | |
145 | expected_tags = [ |
|
140 | expected_tags = ["tags/v0.1", "tags/v0.2", "tags/v0.3", "tags/v0.5"] | |
146 | 'tags/v0.1', 'tags/v0.2', 'tags/v0.3', 'tags/v0.5'] |
|
|||
147 | assert list(repo.tags.keys()) == expected_tags |
|
141 | assert list(repo.tags.keys()) == expected_tags |
General Comments 0
You need to be logged in to leave comments.
Login now