|
8 | 8 | frompathlibimportPath |
9 | 9 | importsubprocess |
10 | 10 |
|
| 11 | +importpytest |
| 12 | + |
11 | 13 | fromgit.objectsimportBlob, Tree |
| 14 | +fromgit.repoimportRepo |
12 | 15 | fromgit.utilimportcwd |
13 | 16 |
|
14 | 17 | fromtest.libimportTestBase, with_rw_directory |
| 18 | +from .lib.helperimportPathLikeMock, with_rw_repo |
15 | 19 |
|
16 | 20 |
|
17 | 21 | classTestTree(TestBase): |
@@ -161,3 +165,57 @@ def lib_folder(t, _d): |
161 | 165 | assertroot[item.path] ==item==root/item.path |
162 | 166 | # END for each item |
163 | 167 | assertfound_slash |
| 168 | + |
| 169 | +@with_rw_repo("0.3.2.1") |
| 170 | +deftest_repo_lookup_string_path(self, rw_repo): |
| 171 | +repo=Repo(rw_repo.git_dir) |
| 172 | +blob=repo.tree() /".gitignore" |
| 173 | +assertisinstance(blob, Blob) |
| 174 | +assertblob.hexsha=="787b3d442a113b78e343deb585ab5531eb7187fa" |
| 175 | + |
| 176 | +@with_rw_repo("0.3.2.1") |
| 177 | +deftest_repo_lookup_pathlike_path(self, rw_repo): |
| 178 | +repo=Repo(rw_repo.git_dir) |
| 179 | +blob=repo.tree() /PathLikeMock(".gitignore") |
| 180 | +assertisinstance(blob, Blob) |
| 181 | +assertblob.hexsha=="787b3d442a113b78e343deb585ab5531eb7187fa" |
| 182 | + |
| 183 | +@with_rw_repo("0.3.2.1") |
| 184 | +deftest_repo_lookup_invalid_string_path(self, rw_repo): |
| 185 | +repo=Repo(rw_repo.git_dir) |
| 186 | +withpytest.raises(KeyError): |
| 187 | +repo.tree() /"doesnotexist" |
| 188 | + |
| 189 | +@with_rw_repo("0.3.2.1") |
| 190 | +deftest_repo_lookup_invalid_pathlike_path(self, rw_repo): |
| 191 | +repo=Repo(rw_repo.git_dir) |
| 192 | +withpytest.raises(KeyError): |
| 193 | +repo.tree() /PathLikeMock("doesnotexist") |
| 194 | + |
| 195 | +@with_rw_repo("0.3.2.1") |
| 196 | +deftest_repo_lookup_nested_string_path(self, rw_repo): |
| 197 | +repo=Repo(rw_repo.git_dir) |
| 198 | +blob=repo.tree() /"git/__init__.py" |
| 199 | +assertisinstance(blob, Blob) |
| 200 | +assertblob.hexsha=="d87dcbdbb65d2782e14eea27e7f833a209c052f3" |
| 201 | + |
| 202 | +@with_rw_repo("0.3.2.1") |
| 203 | +deftest_repo_lookup_nested_pathlike_path(self, rw_repo): |
| 204 | +repo=Repo(rw_repo.git_dir) |
| 205 | +blob=repo.tree() /PathLikeMock("git/__init__.py") |
| 206 | +assertisinstance(blob, Blob) |
| 207 | +assertblob.hexsha=="d87dcbdbb65d2782e14eea27e7f833a209c052f3" |
| 208 | + |
| 209 | +@with_rw_repo("0.3.2.1") |
| 210 | +deftest_repo_lookup_folder_string_path(self, rw_repo): |
| 211 | +repo=Repo(rw_repo.git_dir) |
| 212 | +tree=repo.tree() /"git" |
| 213 | +assertisinstance(tree, Tree) |
| 214 | +asserttree.hexsha=="ec8ae429156d65afde4bbb3455570193b56f0977" |
| 215 | + |
| 216 | +@with_rw_repo("0.3.2.1") |
| 217 | +deftest_repo_lookup_folder_pathlike_path(self, rw_repo): |
| 218 | +repo=Repo(rw_repo.git_dir) |
| 219 | +tree=repo.tree() /PathLikeMock("git") |
| 220 | +assertisinstance(tree, Tree) |
| 221 | +asserttree.hexsha=="ec8ae429156d65afde4bbb3455570193b56f0977" |
0 commit comments