def test_project_is_related_multiple_refs(self): self.conf['ceph'] = { 'hammer': {'ceph-deploy': ['master']}, 'firefly': {'ceph-deploy': ['master']} } result = util.get_related_projects('ceph-deploy', repo_config=self.conf) assert sorted(result['ceph']) == sorted(['hammer', 'firefly'])
def test_project_is_related_with_all_refs(self): self.conf['ceph'] = { 'all': {'ceph-deploy': ['master']}, 'firefly': {'ceph-release': ['firefly']} } result = util.get_related_projects('ceph-deploy', repo_config=self.conf) assert result == {'ceph': ['all']}
def mark_related_repos(self): related_projects = util.get_related_projects(self.project.name) repos = [] projects = [] for project_name, refs in related_projects.items(): p = models.projects.get_or_create(name=project_name) projects.append(p) repo_query = [] if refs == ['all']: # we need all the repos available repo_query = models.Repo.filter_by(project=p).all() else: for ref in refs: repo_query = models.Repo.filter_by(project=p, ref=ref).all() if repo_query: for r in repo_query: repos.append(r) if not repos: # there are no repositories associated with this project, so go ahead # and create one so that it can be queried by the celery task later for project in projects: repo = models.Repo( project, self.ref, self.distro, self.distro_version, sha1=self.sha1, ) repo.needs_update = repository_is_automatic(project.name) repo.type = self.binary._get_repo_type() else: for repo in repos: repo.needs_update = repository_is_automatic(repo.project.name) if repo.type is None: repo.type = self.binary._get_repo_type()
def test_project_is_not_related_when_repeated(self): result = util.get_related_projects('ceph', repo_config=repos_conf) assert result == {}
def test_project_is_related_with_distinct_refs(self): self.conf['ceph'] = { 'firefly': {'ceph-deploy': ['all']} } result = util.get_related_projects('ceph-deploy', repo_config=self.conf) assert result == {'ceph': ['firefly']}
def test_nothing_is_related(self): self.conf['ceph'] = { 'firefly': {'ceph-deploy': ['all']} } result = util.get_related_projects('radosgw-agent', repo_config=self.conf) assert result == {}