##// END OF EJS Templates
tests: fix cache problems after empty repo check change.
marcink -
r3738:b8214661 new-ui
parent child Browse files
Show More
@@ -44,6 +44,7 b' class TestGetRepo(object):'
44 self, apikey_attr, expect_secrets, cache_param, backend,
44 self, apikey_attr, expect_secrets, cache_param, backend,
45 user_util):
45 user_util):
46 repo = backend.create_repo()
46 repo = backend.create_repo()
47 repo_id = repo.repo_id
47 usr = UserModel().get_by_username(TEST_USER_ADMIN_LOGIN)
48 usr = UserModel().get_by_username(TEST_USER_ADMIN_LOGIN)
48 group = user_util.create_user_group(members=[usr])
49 group = user_util.create_user_group(members=[usr])
49 user_util.grant_user_group_permission_to_repo(
50 user_util.grant_user_group_permission_to_repo(
@@ -64,6 +65,8 b' class TestGetRepo(object):'
64 permissions = expected_permissions(repo)
65 permissions = expected_permissions(repo)
65
66
66 followers = []
67 followers = []
68
69 repo = RepoModel().get(repo_id)
67 for user in repo.followers:
70 for user in repo.followers:
68 followers.append(user.user.get_api_data(
71 followers.append(user.user.get_api_data(
69 include_secrets=expect_secrets))
72 include_secrets=expect_secrets))
@@ -84,6 +87,7 b' class TestGetRepo(object):'
84 # TODO: Depending on which tests are running before this one, we
87 # TODO: Depending on which tests are running before this one, we
85 # start with a different number of permissions in the database.
88 # start with a different number of permissions in the database.
86 repo = RepoModel().get_by_repo_name(backend.repo_name)
89 repo = RepoModel().get_by_repo_name(backend.repo_name)
90 repo_id = repo.repo_id
87 permission_count = len(repo.repo_to_perm)
91 permission_count = len(repo.repo_to_perm)
88
92
89 RepoModel().grant_user_permission(repo=backend.repo_name,
93 RepoModel().grant_user_permission(repo=backend.repo_name,
@@ -102,6 +106,8 b' class TestGetRepo(object):'
102 permissions = expected_permissions(repo)
106 permissions = expected_permissions(repo)
103
107
104 followers = []
108 followers = []
109
110 repo = RepoModel().get(repo_id)
105 for user in repo.followers:
111 for user in repo.followers:
106 followers.append(user.user.get_api_data())
112 followers.append(user.user.get_api_data())
107
113
@@ -2465,8 +2465,7 b' class Repository(Base, BaseModel):'
2465 else:
2465 else:
2466 instance = get_instance_cached(*args)
2466 instance = get_instance_cached(*args)
2467
2467
2468 log.debug(
2468 log.debug('Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2469 'Repo instance fetched in %.3fs', inv_context_manager.compute_time)
2470 return instance
2469 return instance
2471
2470
2472 def _get_instance(self, cache=True, config=None):
2471 def _get_instance(self, cache=True, config=None):
@@ -683,6 +683,8 b' class PullRequestModel(BaseModel):'
683
683
684 # source repo
684 # source repo
685 source_repo = pull_request.source_repo.scm_instance()
685 source_repo = pull_request.source_repo.scm_instance()
686 source_repo.count() # cache rebuild
687
686 try:
688 try:
687 source_commit = source_repo.get_commit(commit_id=source_ref_name)
689 source_commit = source_repo.get_commit(commit_id=source_ref_name)
688 except CommitDoesNotExistError:
690 except CommitDoesNotExistError:
@@ -696,6 +698,8 b' class PullRequestModel(BaseModel):'
696
698
697 # target repo
699 # target repo
698 target_repo = pull_request.target_repo.scm_instance()
700 target_repo = pull_request.target_repo.scm_instance()
701 target_repo.count() # cache rebuild
702
699 try:
703 try:
700 target_commit = target_repo.get_commit(commit_id=target_ref_name)
704 target_commit = target_repo.get_commit(commit_id=target_ref_name)
701 except CommitDoesNotExistError:
705 except CommitDoesNotExistError:
@@ -1337,6 +1341,8 b' class PullRequestModel(BaseModel):'
1337 name_or_id = reference.name
1341 name_or_id = reference.name
1338 else:
1342 else:
1339 name_or_id = reference.commit_id
1343 name_or_id = reference.commit_id
1344
1345 vcs_repository.count() # cache rebuild
1340 refreshed_commit = vcs_repository.get_commit(name_or_id)
1346 refreshed_commit = vcs_repository.get_commit(name_or_id)
1341 refreshed_reference = Reference(
1347 refreshed_reference = Reference(
1342 reference.type, reference.name, refreshed_commit.raw_id)
1348 reference.type, reference.name, refreshed_commit.raw_id)
@@ -631,7 +631,9 b' class Backend(object):'
631 commits = commits or [
631 commits = commits or [
632 {'message': 'Commit %s of %s' % (x, self.repo_name)}
632 {'message': 'Commit %s of %s' % (x, self.repo_name)}
633 for x in range(number_of_commits)]
633 for x in range(number_of_commits)]
634 self._add_commits_to_repo(repo.scm_instance(), commits)
634 vcs_repo = repo.scm_instance()
635 vcs_repo.count()
636 self._add_commits_to_repo(vcs_repo, commits)
635 if heads:
637 if heads:
636 self.pull_heads(repo, heads)
638 self.pull_heads(repo, heads)
637
639
General Comments 0
You need to be logged in to leave comments. Login now