Skip to content

Commit

Permalink
Merge pull request #504 from openlawlibrary/renatav/sync-repos-tests-…
Browse files Browse the repository at this point in the history
…improvements

Out-of-sync test improvements
  • Loading branch information
renatav authored Aug 14, 2024
2 parents dd7e7ec + 40040e8 commit 40fbf85
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 153 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ and this project adheres to [Semantic Versioning][semver].
### Added

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

### Fixed

[504]: https://github.com/openlawlibrary/taf/pull/504
[493]: https://github.com/openlawlibrary/taf/pull/493
[489]: https://github.com/openlawlibrary/taf/pull/489
[488]: https://github.com/openlawlibrary/taf/pull/488
Expand Down
17 changes: 14 additions & 3 deletions taf/tests/test_updater/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def execute_tasks(self):
task.function(**task.params)
else:
task.function(**task.params)
# remove all tasks once they are all executed
# allow for the reuse of the setup manager
self.tasks = []
repositoriesdb.clear_repositories_db()


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


def remove_commits(repo_path: str, num_commits: int = 1):
def remove_commits(
auth_repo: AuthenticationRepository,
target_repos: list,
repo_path: str,
num_commits: int = 1,
):
repo = GitRepository(path=Path(repo_path))

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


def pull_specific_target_repo(client_dir: Path, repo_name: str):
client_target_repo = GitRepository(client_dir, repo_name)
def pull_specific_target_repo(
auth_repo: AuthenticationRepository, target_repos: list, repo_path: str
):
client_target_repo = GitRepository(path=repo_path)
client_target_repo.pull()
return


def pull_all_target_repos(auth_repo: AuthenticationRepository, client_dir: Path):
Expand Down
6 changes: 5 additions & 1 deletion taf/tests/test_updater/test_update/test_update_invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ def test_remove_commits_from_target_repo(origin_auth_repo, client_dir):

client_target_repo_path = client_dir / origin_auth_repo.name

remove_commits(str(client_target_repo_path))
setup_manager = SetupManager(origin_auth_repo)
setup_manager.add_task(
remove_commits, kwargs={"repo_path": client_target_repo_path, "num_commits": 1}
)
setup_manager.execute_tasks()

update_invalid_repos_and_check_if_repos_exist(
OperationType.UPDATE,
Expand Down
6 changes: 5 additions & 1 deletion taf/tests/test_updater/test_update/test_update_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ def test_update_valid_remove_commits_from_target_repo(origin_auth_repo, client_d
/ "targets/test_remove_commits_from_target_repo0/target1"
)

remove_commits(str(client_target_repo_path))
setup_manager = SetupManager(origin_auth_repo)
setup_manager.add_task(
remove_commits, kwargs={"repo_path": client_target_repo_path, "num_commits": 1}
)
setup_manager.execute_tasks()

update_and_check_commit_shas(
OperationType.UPDATE,
Expand Down
Loading

0 comments on commit 40fbf85

Please sign in to comment.