예제 #1
0
 def __init__(self, ref_name):
     self.ref_name = ref_name
     self.project = Project.get(request.context['project_id'])
     if not self.project:
         # TODO: nice project not found error template
         abort(404, 'project not found')
     request.context['ref'] = ref_name
예제 #2
0
 def __init__(self, ref_name):
     self.ref_name = ref_name
     self.project = Project.get(request.context['project_id'])
     if not self.project:
         # TODO: nice project not found error template
         abort(404, 'project not found')
     request.context['ref'] = ref_name
예제 #3
0
    def test_list_a_few_projects(self, session):
        for p in range(20):
            Project('foo_%s' % p)
        session.commit()

        result = session.app.get('/api/repos/')
        assert result.status_int == 200
        assert len(result.json) == 20
예제 #4
0
 def __init__(self, _id):
     self.project = Project.get(request.context['project_id'])
     self.build = Build.get(_id)
     if not self.project:
         # TODO: nice project not found error template
         abort(404, 'project not found')
     if not self.build:
         # TODO: nice project not found error template
         abort(404, 'build not found')
예제 #5
0
 def __init__(self, _id):
     self.project = Project.get(request.context['project_id'])
     self.build = Build.get(_id)
     if not self.project:
         # TODO: nice project not found error template
         abort(404, 'project not found')
     if not self.build:
         # TODO: nice project not found error template
         abort(404, 'build not found')
예제 #6
0
파일: flavors.py 프로젝트: ktdreyer/shaman
    def index_get(self):
        project = Project.get(request.context['project_id'])
        repos = Repo.query.filter_by(
            project=project,
            ref=request.context['ref'],
            sha1=request.context['sha1'],
            distro=request.context['distro'],
            distro_version=request.context['distro_version']).all()

        return [r.flavor for r in repos]
예제 #7
0
    def index_get(self):
        project = Project.get(request.context['project_id'])
        repos = Repo.query.filter_by(
            project=project,
            ref=request.context['ref'],
            sha1=request.context['sha1'],
            distro=request.context['distro'],
            distro_version=request.context['distro_version']).all()

        return [r.flavor for r in repos]
예제 #8
0
 def setup(self):
     self.p = Project("ceph")
     self.data = dict(
         ref="master",
         sha1="sha1",
         url="jenkins.ceph.com/build",
         log_url="jenkins.ceph.com/build/console",
         build_id="250",
         status="failed",
     )
예제 #9
0
 def test_list_sha1s_by_id(self, session):
     project = Project(name='ceph')
     Build(build_id=1, project=project, ref='master', sha1='1234')
     Build(build_id=2, project=project, ref='master', sha1='1234')
     Build(build_id=100, project=project, ref='master', sha1='1234')
     commit()
     result = session.app.get('/builds/ceph/master/1234/')
     assert result.namespace['builds'][0].build_id == '100'
     assert result.namespace['builds'][1].build_id == '2'
     assert result.namespace['builds'][2].build_id == '1'
예제 #10
0
 def apply_filters(self, filters):
     # TODO: allow operators
     filters = deepcopy(filters)
     try:
         project = Project.filter_by(name=filters.pop('project')).first()
         query = Repo.filter_by(project=project)
     except KeyError:
         query = Repo.query
     if filters.get("distros", None):
         # TODO: we'll need some sort of schema validation here
         distro_list = util.parse_distro_query(filters.pop("distros"))
         distro_filter_list = []
         has_arch_filter = False
         for distro in distro_list:
             # for deb-based distros we store codename in the db as version,
             # so try first with the codename, but fallback to
             # distro_version otherwise
             version_filter = distro["distro_codename"] or distro['distro_version']
             if not version_filter:
                 abort(400, "Invalid version or codename for distro: %s" % distro["distro"])
             repo_filters = [Repo.distro == distro["distro"], Repo.distro_version == version_filter]
             if distro["arch"]:
                 repo_filters.append(Arch.name == distro["arch"])
                 has_arch_filter = True
             distro_filter_list.append(
                 and_(*repo_filters)
             )
         if has_arch_filter:
             query = query.join(Repo.archs).filter(or_(*distro_filter_list))
         else:
             query = query.filter(or_(*distro_filter_list))
     for k, v in filters.items():
         if k not in self.filters:
             # TODO: improve error reporting
             # 'invalid query params: %s' % k
             abort(400)
         if k in self.filters:
             query = self.filter_repo(k, v, query)
     return query
예제 #11
0
 def test_get_index_shows_projects(self, session):
     Project("ceph")
     session.commit()
     result = session.app.get('/api/')
     assert result.status_int == 200
     assert result.json == {'repos': ['ceph']}
예제 #12
0
 def test_get_project_repos_is_empty(self, session):
     Project("ceph")
     session.commit()
     result = session.app.get('/api/repos/ceph/')
     assert result.json == []
예제 #13
0
 def test_one_project_list_length(self, session):
     Project("ceph")
     session.commit()
     result = session.app.get('/api/repos/')
     assert result.status_int == 200
     assert len(result.json.keys()) == 1
예제 #14
0
 def test_list_a_project(self, session):
     Project("ceph")
     session.commit()
     result = session.app.get('/api/repos/')
     assert result.status_int == 200
     assert "ceph" in result.json.keys()
예제 #15
0
 def setup(self):
     self.p = Project("ceph")
     self.data = dict(
         distro="ubuntu",
         distro_version="trusty",
     )
예제 #16
0
 def setup(self):
     self.p = Project("ceph")
     self.data = base_repo_data()
     self.repo = Repo(self.p, **self.data)
     Arch(name="x86_64", repo=self.repo)