Skip to content

Commit 40fbf85

Browse files
authored
Merge pull request #504 from openlawlibrary/renatav/sync-repos-tests-improvements
Out-of-sync test improvements
2 parents dd7e7ec + 40040e8 commit 40fbf85

File tree

7 files changed

+146
-153
lines changed

7 files changed

+146
-153
lines changed

CHANGELOG.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning][semver].
1010
### Added
1111

1212
- Allow for the displaying of varied levels of log and debug information based on the verbosity level ([493])
13-
- Added new tests to test out of sync repositories and manual updates [488]
14-
- Added lazy loading to CLI [481]
13+
- Added new tests to test out of sync repositories and manual updates ([488], [504])
14+
- Added lazy loading to CLI ([481])
1515
- Testing repositories with dependencies ([479], [487])
1616
- Hid plaintext when users are prompted to insert YubiKey and press ENTER ([473])
1717
- Added functionality for parallel execution of child repo during clone and update for performance enhancement ([472])
@@ -37,6 +37,7 @@ and this project adheres to [Semantic Versioning][semver].
3737

3838
### Fixed
3939

40+
[504]: https://github.com/openlawlibrary/taf/pull/504
4041
[493]: https://github.com/openlawlibrary/taf/pull/493
4142
[489]: https://github.com/openlawlibrary/taf/pull/489
4243
[488]: https://github.com/openlawlibrary/taf/pull/488

taf/tests/test_updater/conftest.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ def execute_tasks(self):
158158
task.function(**task.params)
159159
else:
160160
task.function(**task.params)
161+
# remove all tasks once they are all executed
162+
# allow for the reuse of the setup manager
163+
self.tasks = []
161164
repositoriesdb.clear_repositories_db()
162165

163166

@@ -648,7 +651,12 @@ def add_file_without_commit(repo_path: str, filename: str):
648651
file.write(text_to_add)
649652

650653

651-
def remove_commits(repo_path: str, num_commits: int = 1):
654+
def remove_commits(
655+
auth_repo: AuthenticationRepository,
656+
target_repos: list,
657+
repo_path: str,
658+
num_commits: int = 1,
659+
):
652660
repo = GitRepository(path=Path(repo_path))
653661

654662
try:
@@ -680,9 +688,12 @@ def set_head_commit(auth_repo: AuthenticationRepository):
680688
raise ValueError("Failed to retrieve the last valid commit SHA.")
681689

682690

683-
def pull_specific_target_repo(client_dir: Path, repo_name: str):
684-
client_target_repo = GitRepository(client_dir, repo_name)
691+
def pull_specific_target_repo(
692+
auth_repo: AuthenticationRepository, target_repos: list, repo_path: str
693+
):
694+
client_target_repo = GitRepository(path=repo_path)
685695
client_target_repo.pull()
696+
return
686697

687698

688699
def pull_all_target_repos(auth_repo: AuthenticationRepository, client_dir: Path):

taf/tests/test_updater/test_update/test_update_invalid.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ def test_remove_commits_from_target_repo(origin_auth_repo, client_dir):
204204

205205
client_target_repo_path = client_dir / origin_auth_repo.name
206206

207-
remove_commits(str(client_target_repo_path))
207+
setup_manager = SetupManager(origin_auth_repo)
208+
setup_manager.add_task(
209+
remove_commits, kwargs={"repo_path": client_target_repo_path, "num_commits": 1}
210+
)
211+
setup_manager.execute_tasks()
208212

209213
update_invalid_repos_and_check_if_repos_exist(
210214
OperationType.UPDATE,

taf/tests/test_updater/test_update/test_update_valid.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,11 @@ def test_update_valid_remove_commits_from_target_repo(origin_auth_repo, client_d
532532
/ "targets/test_remove_commits_from_target_repo0/target1"
533533
)
534534

535-
remove_commits(str(client_target_repo_path))
535+
setup_manager = SetupManager(origin_auth_repo)
536+
setup_manager.add_task(
537+
remove_commits, kwargs={"repo_path": client_target_repo_path, "num_commits": 1}
538+
)
539+
setup_manager.execute_tasks()
536540

537541
update_and_check_commit_shas(
538542
OperationType.UPDATE,

0 commit comments

Comments
 (0)