Пример #1
0
 def test_get_index_ref_with_sha1s(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.rpm', p, ref='master', sha1="sha1", distro='centos', distro_version='el6', arch='i386')
     Binary('ceph-1.0.0.deb', p, ref='master', sha1="head", distro='ubuntu', distro_version='trusty', arch='i386')
     session.commit()
     result = session.app.get('/binaries/ceph/master/')
     assert set(result.json.keys()) == set(['head', 'sha1'])
Пример #2
0
 def test_search_by_distro_gets_more_than_one_item(self, session):
     project = Project('ceph')
     Binary('ceph-1.0.0.rpm', project, ref='giant', distro='centos', distro_version='el6', arch='x86_64')
     Binary('ceph-1.0.0.rpm', project, ref='giant', distro='centos', distro_version='el7', arch='x86_64')
     session.commit()
     result = session.app.get('/search/?distro=centos')
     assert len(result.json) == 2
Пример #3
0
 def test_list_unique_flavor(self, session):
     project = Project('ceph')
     Binary(
         'ceph-1.0.0.rpm',
         project,
         ref='giant',
         sha1="head",
         distro='centos',
         distro_version='el6',
         arch='x86_64',
         flavor='tcmalloc'
     )
     Binary(
         'ceph-1.0.0.rpm',
         project,
         ref='giant',
         sha1="head",
         distro='centos',
         distro_version='el7',
         arch='x86_64',
         flavor='tcmalloc'
     )
     session.commit()
     result = session.app.get(
         '/binaries/ceph/giant/head/centos/el6/x86_64/flavors/',
     )
     assert result.json['tcmalloc'] == ['ceph-1.0.0.rpm']
Пример #4
0
 def test_list_one_flavor(self, session):
     project = Project('ceph')
     Binary(
         'ceph-1.0.0.rpm',
         project,
         ref='giant',
         sha1="head",
         distro='centos',
         distro_version='el6',
         arch='x86_64',
         flavor='tcmalloc'
     )
     Binary(
         'ceph-1.0.0.rpm',
         project,
         ref='giant',
         sha1="head",
         distro='centos',
         distro_version='el7',
         arch='x86_64',
         flavor='default'
     )
     session.commit()
     result = session.app.get(
         '/binaries/ceph/giant/head/centos/el6/x86_64/flavors/',
     )
     # default flavor is for a different distro_version in this case
     # and should not show up
     assert result.json.keys() == ['tcmalloc']
Пример #5
0
 def test_list_a_distinct_distro(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.deb', p, ref='master', distro='ubuntu', distro_version='trusty', arch='i386')
     Binary('ceph-1.0.0.rpm', p, ref='master', distro='centos', distro_version='el6', arch='i386')
     session.commit()
     result = session.app.get('/projects/ceph/master/ubuntu/')
     assert result.json == {'trusty': ['i386']}
Пример #6
0
 def test_get_index_ref_with_distros(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.rpm', p, ref='master', distro='centos', distro_version='el6', arch='i386')
     Binary('ceph-1.0.0.deb', p, ref='master', distro='ubuntu', distro_version='trusty', arch='i386')
     session.commit()
     result = session.app.get('/projects/ceph/master/')
     assert result.json.keys() == ['centos', 'ubuntu']
Пример #7
0
 def test_distro_should_list_unique_versions(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.deb', p, ref='master', distro='ubuntu', distro_version='trusty', arch='i386')
     Binary('ceph-1.0.1.deb', p, ref='master', distro='ubuntu', distro_version='trusty', arch='i386')
     session.commit()
     result = session.app.get('/projects/ceph/master/ubuntu/trusty/')
     assert result.json == {u'i386': [u'ceph-1.0.1.deb', u'ceph-1.0.0.deb']}
Пример #8
0
 def test_get_project_refs(self, session):
     p = Project('foobar')
     Binary('ceph-1.0.0.rpm', p, ref='master', sha1="HEAD", distro='centos', distro_version='el6', arch='i386')
     Binary('ceph-1.0.0.rpm', p, ref='firefly', sha1="HEAD", distro='centos', distro_version='el6', arch='i386')
     session.commit()
     result = session.app.get('/binaries/foobar/')
     assert result.json == {'firefly': ['HEAD'], 'master': ['HEAD']}
Пример #9
0
 def test_search_like_name(self, session):
     project = Project('ceph')
     Binary('ceph-1.0.0.rpm', project, ref='giant', distro='centos', distro_version='el6', arch='x86_64')
     Binary('radosgw-agent-1.0.0.rpm', project, ref='giant', distro='centos', distro_version='el7', arch='x86_64')
     session.commit()
     result = session.app.get('/search/?name-has=ceph')
     assert len(result.json) == 1
     assert result.json[0]['name'] == 'ceph-1.0.0.rpm'
Пример #10
0
 def test_get_ref_with_distinct_sha1s(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.rpm', p, ref='master', sha1="sha1", distro='centos', distro_version='el6', arch='i386')
     # note how we are using a different ref
     Binary('ceph-1.0.0.deb', p, ref='firefly', sha1="head", distro='ubuntu', distro_version='trusty', arch='i386')
     session.commit()
     result = session.app.get('/binaries/ceph/master/')
     assert list(result.json.keys()) == ['sha1']
Пример #11
0
    def index_post(self):
        contents = request.POST.get('file', False)
        if self.binary is not None:
            if os.path.exists(self.binary.path):
                if request.POST.get('force', False) is False:
                    error(
                        '/errors/invalid',
                        "resource already exists and 'force' flag was not set")
        if contents is False:
            error('/errors/invalid/',
                  'no file object found in "file" param in POST request')
        file_obj = contents.file
        full_path = self.save_file(file_obj)

        if self.binary is None:
            path = full_path
            distro = request.context['distro']
            distro_version = request.context['distro_version']
            arch = request.context['arch']
            ref = request.context['ref']

            Binary(self.binary_name,
                   self.project,
                   arch=arch,
                   distro=distro,
                   distro_version=distro_version,
                   ref=ref,
                   path=path,
                   size=os.path.getsize(path))
        else:
            self.binary.path = full_path
        return dict()
Пример #12
0
 def test_single_distro_should_have_one_item(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.deb', p, ref='master', distro='ubuntu', distro_version='12.04', arch='i386')
     session.commit()
     result = session.app.get('/projects/ceph/master/ubuntu/')
     assert result.status_int == 200
     assert len(result.json) == 1
Пример #13
0
 def test_single_distro_should_have_a_name(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.deb', p, ref='master', distro='ubuntu', distro_version='12.04', arch='i386')
     session.commit()
     result = session.app.get('/projects/ceph/master/ubuntu/')
     print result
     assert result.json['12.04'] == ['i386']
Пример #14
0
 def test_multiple_archs(self, session):
     Binary(
         'ceph-1.0.deb',
         self.p,
         distro='ubuntu',
         distro_version='trusty',
         arch='aarch64',
     )
     Binary(
         'ceph-1.0.deb',
         self.p,
         distro='ubuntu',
         distro_version='trusty',
         arch='x86_64',
     )
     session.commit()
     repo = Repo.get(1)
     assert sorted(repo.archs) == sorted(['aarch64', 'x86_64'])
Пример #15
0
 def test_binary_is_not_generic(self, session):
     binary = Binary(
         'ceph-1.0.deb',
         self.p,
         ref='hammer',
         distro='debian',
         distro_version='wheezy',
         arch='amd64',
     )
     assert binary.repo.is_generic is False
Пример #16
0
 def test_search_by_distro_gets_full_metadata(self, session):
     project = Project('ceph')
     Binary('ceph-1.0.0.rpm', project, ref='giant', distro='centos', distro_version='el6', arch='x86_64')
     session.commit()
     result = session.app.get('/search/?distro=centos').json[0]
     assert result['name'] == 'ceph-1.0.0.rpm'
     assert result['distro'] == 'centos'
     assert result['distro_version'] == 'el6'
     assert result['arch'] == 'x86_64'
     assert result['ref'] == 'giant'
Пример #17
0
 def test_rpm_is_inferred(self, session):
     Binary(
         'ceph-1.0.rpm',
         self.p,
         distro='centos',
         distro_version='7',
         arch='x86_64',
     )
     session.commit()
     repo = Repo.get(1)
     assert repo.infer_type() == 'rpm'
Пример #18
0
 def test_deb_is_inferred(self, session):
     Binary(
         'ceph-1.0.deb',
         self.p,
         distro='ubuntu',
         distro_version='trusty',
         arch='x86_64',
     )
     session.commit()
     repo = Repo.get(1)
     assert repo.infer_type() == 'deb'
Пример #19
0
 def test_x86_64(self, session):
     Binary(
         'ceph-1.0.rpm',
         self.p,
         distro='centos',
         distro_version='7',
         arch='x86_64',
     )
     session.commit()
     repo = Repo.get(1)
     assert repo.archs == ['x86_64']
Пример #20
0
 def test_binary_type_for_tar(self, session):
     repo = Repo(self.p, 'hammer', 'debian', 'wheezy')
     Binary(
         'ceph-1.0.tar.gz',
         self.p,
         ref='hammer',
         distro='debian',
         distro_version='wheezy',
         arch='amd64',
     )
     assert repo.type == 'deb'
Пример #21
0
 def test_get_index_single_ref(self, session):
     p = Project('ceph')
     Binary('ceph-1.0.0.rpm',
            p,
            ref='master',
            sha1="head",
            distro='centos',
            distro_version='el6',
            arch='i386')
     session.commit()
     result = session.app.get('/binaries/ceph/master/')
     assert result.json == {'head': ['centos']}
Пример #22
0
 def test_binary_create_repo_object(self, session):
     binary = Binary(
         'ceph-1.0.rpm',
         self.p,
         ref='firefly',
         distro='centos',
         distro_version='7',
         arch='x86_64',
     )
     session.commit()
     binary = Binary.get(1)
     assert binary.repo.ref == 'firefly'
     assert binary.repo.distro_version == '7'
Пример #23
0
 def test_single_binary_should_have_default_size_cero(self, session):
     p = Project('ceph')
     Binary('ceph-9.0.0-0.el6.x86_64.rpm',
            p,
            ref='giant',
            sha1="head",
            distro='centos',
            distro_version='el6',
            arch='x86_64')
     session.commit()
     result = session.app.get(
         '/binaries/ceph/giant/head/centos/el6/x86_64/')
     assert result.json['ceph-9.0.0-0.el6.x86_64.rpm']['size'] == 0
Пример #24
0
 def test_arch_not_found_with_head(self, session):
     project = Project('ceph')
     Binary('ceph-1.0.0.rpm',
            project,
            ref='giant',
            sha1="head",
            distro='centos',
            distro_version='el6',
            arch='x86_64')
     session.commit()
     result = session.app.head(
         '/binaries/ceph/giant/head/centos/el7/x86_64/', expect_errors=True)
     assert result.status_int == 404
Пример #25
0
 def test_list_arch_one_binary(self, session):
     project = Project('ceph')
     Binary('ceph-1.0.0.rpm',
            project,
            ref='giant',
            sha1="head",
            distro='centos',
            distro_version='el6',
            arch='x86_64')
     session.commit()
     result = session.app.get(
         '/binaries/ceph/giant/head/centos/el6/x86_64/')
     assert result.json['ceph-1.0.0.rpm']
Пример #26
0
 def test_binary_file_deletes_object_with_no_path(self, session, url):
     p = Project("ceph")
     Binary(
         "ceph-9.0.0-0.el6.x86_64.rpm",
         p,
         distro="ceph",
         distro_version="el6",
         ref="giant",
         arch="x86_64",
         sha1="head",
     )
     result = session.app.delete(url, expect_errors=True)
     assert result.status_int == 204
Пример #27
0
 def test_repo_endpoint_rpm(self, session, url):
     p = Project('foobar')
     Binary(
         'ceph-1.0.rpm',
         p,
         distro='centos',
         distro_version='7',
         arch='x86_64',
         sha1="head",
         ref="firefly",
     )
     session.commit()
     result = session.app.get(url)
     assert b_("[foobar]") in result.body
Пример #28
0
 def test_single_arch_should_have_one_item(self, session):
     p = Project('ceph')
     Binary('ceph-9.0.0-0.el6.x86_64.rpm',
            p,
            ref='giant',
            sha1="head",
            distro='centos',
            distro_version='el6',
            arch='x86_64')
     session.commit()
     result = session.app.get(
         '/binaries/ceph/giant/head/centos/el6/x86_64/')
     assert result.status_int == 200
     assert len(result.json) == 1
Пример #29
0
 def test_repo_archs(self, session, url):
     p = Project('foobar')
     Binary(
         'ceph-1.0.deb',
         p,
         distro='ubuntu',
         distro_version='trusty',
         arch='x86_64',
         sha1="head",
         ref="firefly",
     )
     session.commit()
     result = session.app.get(url)
     assert result.json['archs'] == ['x86_64']
Пример #30
0
 def test_repo_endpoint_deb(self, session, url):
     p = Project('foobar')
     Binary(
         'ceph-1.0.deb',
         p,
         distro='ubuntu',
         distro_version='trusty',
         arch='x86_64',
         sha1="head",
         ref="firefly",
     )
     session.commit()
     result = session.app.get(url)
     assert b_("deb") in result.body