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'])
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
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']
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']
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']}
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']
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']}
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']}
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'
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']
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()
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
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']
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'])
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
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'
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'
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'
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']
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'
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']}
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'
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
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
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']
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
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
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
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']
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