def testcase_01_create_delete_upload(self):
        '''test creating uploads works'''
        upload = Upload.create(self.pulp)
        # assert what was created is what is kept locally
        ids = Upload.list(self.pulp)
        assert upload.id in ids, 'could not find id %s on server (%s)' % (upload.id, ids)
        # assert GET doesn't work
        with self.assertRaises(TypeError):
            Upload.get(self.pulp, upload.id)

        # assert deleting works
        upload.delete(self.pulp)
        self.assertPulpOK()
        ids = Upload.list(self.pulp)
        assert upload.id not in ids, 'upload %s deleted but still on server (%s)' % (upload.id, ids)
Ejemplo n.º 2
0
    def testcase_01_create_delete_upload(self):
        '''test creating uploads works'''
        upload = Upload.create(self.pulp)
        # assert what was created is what is kept locally
        ids = Upload.list(self.pulp)
        assert upload.id in ids, 'could not find id %s on server (%s)' % (upload.id, ids)
        # assert GET doesn't work
        with self.assertRaises(TypeError):
            Upload.get(self.pulp, upload.id)

        # assert deleting works
        upload.delete(self.pulp)
        self.assertPulpOK()
        ids = Upload.list(self.pulp)
        assert upload.id not in ids, 'upload %s deleted but still on server (%s)' % (upload.id, ids)
Ejemplo n.º 3
0
    def test_01_package_category_create(self):
        response = self.repo1.within_repo_search(
            self.pulp,
            data={"criteria": {"type_ids": ["package_group"],"limit": 1}}
        )
        self.assertPulp(code=200)
        result = Association.from_response(response)
        groupList = []
        # make a list of names
        for i in range(0, len(result)):
            groupList.append(result[i].data['metadata']['name'])
        #create metadata for package category import
        data = package_category_metadata(self.repo1.id+"_category1", self.repo1.id, groupList)

        #actually upload category
        with deleting(self.pulp, Upload.create(self.pulp, data=data)) as (upload,) :
            Task.wait_for_report(self.pulp, upload.import_to(self.pulp, self.repo1))
        self.assertPulp(code=200)

        #check that group is there and contains specified packages
        response = self.repo1.within_repo_search(
            self.pulp,
            data={"criteria": {"type_ids": ["package_category"],\
                  "filters": {"unit": {"id": data["unit_key"]["id"]}}}}
        )
        self.assertPulp(code=200)
        result = Association.from_response(response)
        self.assertEqual(result[0].data["metadata"]["packagegroupids"],
                         data["unit_metadata"]["packagegroupids"])
Ejemplo n.º 4
0
def upload_url_iso(pulp, url):
    '''create an upload object fed from the url'''
    # get basename for upload purpose
    basename = url_basename(url)
    with closing(temp_url(url)) as tmpfile:
        data = iso_metadata(tmpfile.file)
        # augment iso file name
        data['unit_key']['name'] = basename
        upload = Upload.create(pulp, data=data)
        # feed the data
        tmpfile.file.seek(0)
        upload.file(pulp, tmpfile.file)
    return upload
Ejemplo n.º 5
0
def upload_url_rpm(pulp, url):
    '''create an upload object fed from the url'''
    # get basename for upload purpose
    basename = url_basename(url)
    with closing(temp_url(url)) as tmpfile:
        data = rpm_metadata(tmpfile.file)
        # augment rpm file name
        data['unit_metadata']['relativepath'] = basename
        data['unit_metadata']['filename'] = basename
        upload = Upload.create(pulp, data=data)
        # feed the data
        tmpfile.file.seek(0)
        upload.file(pulp, tmpfile.file)
    return upload
def upload_url_rpm(pulp, url):
    '''create an upload object fed from the url'''
    # get basename for upload purpose
    basename = url_basename(url)
    with closing(temp_url(url)) as tmpfile:
        data = rpm_metadata(tmpfile.file)
        # augment rpm file name
        data['unit_metadata']['relativepath'] = basename
        data['unit_metadata']['filename'] = basename
        upload = Upload.create(pulp, data=data)
        # feed the data
        tmpfile.file.seek(0)
        upload.file(pulp, tmpfile.file)
    return upload
    def test_03_package_group_copy(self):
        response = self.repo1.within_repo_search(
            self.pulp,
            data={"criteria": {"type_ids": ["rpm"],"limit": 5}}
        )
        self.assertPulp(code=200)
        result = Association.from_response(response)
        rpmlist = []
        # make a list of names
        for i in range(0, len(result)):
            rpmlist.append(result[i].data['metadata']['name'])
        #create metadata for package group import
        data = package_group_metadata(self.repo1.id+"_group3", self.repo1.id, rpmlist)
        #actually upload group
        with deleting(self.pulp, Upload.create(self.pulp, data=data)) as (upload,):
            Task.wait_for_report(self.pulp, upload.import_to(self.pulp, self.repo1))
        self.assertPulp(code=200)

        #copy group to other repo
        response = self.repo2.copy(
            self.pulp,
            self.repo1.id,
            data={
                'criteria': {
                'type_ids': ['package_group'],
                'filters': {"unit": {"name": data["unit_metadata"]["name"]}}
                },
            }
        )
        self.assertPulp(code=202)
        Task.wait_for_report(self.pulp, response)

        #check that group is there and contains specified packages
        response = self.repo2.within_repo_search(
            self.pulp,
            data={"criteria": {"type_ids": ["package_group"],\
                  "filters": {"unit": {"id": data["unit_key"]["id"]}}}}
        )
        self.assertPulp(code=200)
        result = Association.from_response(response)
        self.assertEqual(result[0].data["metadata"]["mandatory_package_names"],
                         data["unit_metadata"]["mandatory_package_names"])
Ejemplo n.º 8
0
    def test_02_package_category_delete(self):
        groupList = []
        #create metadata for package category import
        data = package_category_metadata(self.repo1.id+"_category1", self.repo1.id, groupList)
        #actually upload category
        with deleting(self.pulp, Upload.create(self.pulp, data=data)) as (upload,):
            Task.wait_for_report(self.pulp, upload.import_to(self.pulp, self.repo1))
        self.assertPulp(code=200)

        item={"criteria": {"type_ids": ["package_category"],\
                  "filters": {"unit": {"id": data["unit_key"]["id"]}}}}
        response = self.repo1.unassociate_units(self.pulp, item)
        self.assertPulp(code=202)
        Task.wait_for_report(self.pulp, response)
        #check that group is NOT there and contains specified packages
        response = self.repo1.within_repo_search(
            self.pulp,
            data={"criteria": {"type_ids": ["package_category"],\
                  "filters": {"unit": {"id": data["unit_key"]["id"]}}}}
        )
        self.assertPulp(code=200)
        result = Association.from_response(response)
        self.assertEqual(len(result), 0)