New tests, Cloner.sync() without tests, but recursive
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import git
|
||||
import pytest
|
||||
from repo_cloner.lib.checksum import gen_repo_hashed_name
|
||||
import repo_cloner.lib.dir_not_found_error
|
||||
from repo_cloner.lib import gen_repo_hashed_name, DirNotFoundError, Cloner
|
||||
from cloner_test_fixtures import *
|
||||
from repo_cloner.lib.cloner import Cloner
|
||||
from pathlib import Path
|
||||
import logging
|
||||
import unittest.mock
|
||||
from unittest.mock import patch, PropertyMock
|
||||
|
||||
|
||||
def mock_time() -> float:
|
||||
@@ -35,7 +33,7 @@ class MockDirStruct:
|
||||
@property
|
||||
def cache_dir_exists(self):
|
||||
if self.raise_cache_exists:
|
||||
raise repo_cloner.lib.dir_not_found_error.DirNotFoundError("mock_dir")
|
||||
raise DirNotFoundError("mock_dir")
|
||||
return True
|
||||
|
||||
|
||||
@@ -266,7 +264,6 @@ def test_clone_initialized(tmp_path, path_repo_base, caplog):
|
||||
|
||||
|
||||
def test_clone_recursive(tmp_path, path_repo_base, caplog):
|
||||
from unittest.mock import patch, PropertyMock
|
||||
mock = MockDirStruct(tmp_path)
|
||||
mock.config.cloner_repo_url = "https://repo"
|
||||
mock.config.cloner_submodules = True
|
||||
|
||||
@@ -458,6 +458,36 @@ def test_fingerprint(support_data_path: Path, repo: str, hash):
|
||||
assert rt.repo_fingerprint() == hash
|
||||
|
||||
|
||||
def test_list_commits_unopened(tmp_path):
|
||||
rt = RepoTool(tmp_path)
|
||||
assert not rt.list_commits()
|
||||
|
||||
|
||||
def test_list_commits(cloned_base_repo_obj):
|
||||
assert cloned_base_repo_obj.list_commits(3)
|
||||
count = 0
|
||||
commits = set()
|
||||
for commit in cloned_base_repo_obj.list_commits(20):
|
||||
count += 1
|
||||
commits.add(commit.hexsha)
|
||||
assert count == 20
|
||||
|
||||
assert commits == {
|
||||
'93e97409040f6e4ba5cebc4ddca679a2d3203efa', 'd8cd3257e05dc4a3d0061b5320ef5efd0b45d840',
|
||||
'f916de4ff4c65b93250716354917488ea480f592', 'd6b1a8d59185437ea2fd0055700b4656707ba2d2',
|
||||
'10c0963c6ded9e41bcb82cf524661d00383d07b4', '06bdaca2c1bbb0b599fdace8698214f82c5850d6',
|
||||
'95d31440dbcaf38e596e6b712d0d288215ce2a56', '86dab14dfdb87738fe7ff3613222dffb6dd2f796',
|
||||
'558f12143c6d6d60690acb291cf64a863e12c2d0', '30c00bf3850ec01341c7961a251dee2c4d4cb771',
|
||||
'7bc1195651dd8bbc62bcc52edf6d07923b2d4f1a', '2cd8137eeb96e2d23169d5728e9071b0ed663677',
|
||||
'786c4412069526051cbbce6a87e76a63aa64f1e7', '143637c4fc05837d238c0ca67543a4494c07cc85',
|
||||
'fa0c7b9ac17a342b51fb5414317b54a5dfd2074b', '77f77c3e8bca3f5b43b6f55a88d619b30f6a6ae0',
|
||||
'b3615798ace53b983251a57593b328e707a8f419', 'e0c7e2a72579e24657c05e875201011d2b48bf94',
|
||||
'c090c23662933aa5fbbc6385bfae17e316e56a84', '4f5e3068cce0bc562a1ac7719915a86a6d01283e'
|
||||
}
|
||||
|
||||
assert 339 == sum(1 for commit in cloned_base_repo_obj.list_commits())
|
||||
|
||||
|
||||
def test_list_submodules_no_submodules(cloned_base_repo_obj):
|
||||
assert cloned_base_repo_obj.list_submodules() == []
|
||||
assert cloned_base_repo_obj.discovered_submodules_commits == ["e0c7e2a72579e24657c05e875201011d2b48bf94"]
|
||||
|
||||
Reference in New Issue
Block a user