| 245 | @utils.requires_network |
| 246 | @pytest.mark.parametrize('depth', [0, 1]) |
| 247 | def test_add_submodule(repo: Repository, depth: int) -> None: |
| 248 | sm_repo_path = 'test/testrepo' |
| 249 | sm = repo.submodules.add(SUBM_URL, sm_repo_path, depth=depth) |
| 250 | |
| 251 | status = repo.submodules.status(sm_repo_path) |
| 252 | assert status == (SS.IN_INDEX | SS.IN_CONFIG | SS.IN_WD | SS.INDEX_ADDED) |
| 253 | |
| 254 | sm_repo = sm.open() |
| 255 | assert sm_repo_path == sm.path |
| 256 | assert SUBM_URL == sm.url |
| 257 | assert not sm_repo.is_empty |
| 258 | |
| 259 | if depth == 0: |
| 260 | sm_repo[SUBM_BOTTOM_SHA] # full history must be available |
| 261 | else: |
| 262 | with pytest.raises(KeyError): |
| 263 | sm_repo[SUBM_BOTTOM_SHA] # shallow clone |
| 264 | |
| 265 | |
| 266 | @utils.requires_network |