예제 #1
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"])
 def test_03_search_invalid_modules(self):
     response = self.repo.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "yum"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
 def test_06_check_iso_was_unassociated(self):
     # perform a search within the repo
     response = self.dest_repo1.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["iso"], "filters": {"unit": {"name": "test.iso"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
 def test_08_check_module_was_unassociated(self):
     # perform a search within the repo
     response = self.source_repo.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
 def test_01_search_modules_within_metadata(self):
     response = self.repo.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # check that filter works properly and in the result there are only modules with name 'tomcat'
     for i in range(0, len(result)):
         self.assertEqual("tomcat", result[i].data["metadata"]["name"])
예제 #6
0
 def test_08_check_module_was_unassociated(self):
     #perform a search within the repo
     response = self.source_repo.within_repo_search(
         self.pulp,
         data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
    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"])
 def test_02_search_modules_outside_metadata(self):
     #get unit id from inside the metadata
     response = self.repo.within_repo_search(
         self.pulp,
         data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}}
     )
     self.assertPulp(code=200)
     result_old = Association.from_response(response)
     unit_id = result_old[0].data['metadata']['_id']
     # perform search outside the metadata, i.e search in the association data
     response = self.repo.within_repo_search(
         self.pulp,
         data={"criteria": {"type_ids": ["puppet_module"], "filters": {"association": {"unit_id": unit_id}}}}
     )
     self.assertPulp(code=200)
     result_new = Association.from_response(response)
     #check that there is only one module with this id
     self.assertTrue(len(result_new) == 1)
     #check that the search inside and outside metadata is consistent
     self.assertIn(Association(data={'unit_id':unit_id}, required_data_keys=['unit_id'], relevant_data_keys=['unit_id']), result_new)
 def test_02_search_modules_outside_metadata(self):
     #get unit id from inside the metadata
     response = self.repo.within_repo_search(self.pulp,
                                             data={
                                                 "criteria": {
                                                     "type_ids":
                                                     ["puppet_module"],
                                                     "filters": {
                                                         "unit": {
                                                             "name":
                                                             "tomcat7_rhel"
                                                         }
                                                     }
                                                 }
                                             })
     self.assertPulp(code=200)
     result_old = Association.from_response(response)
     unit_id = result_old[0].data['metadata']['_id']
     # perform search outside the metadata, i.e search in the association data
     response = self.repo.within_repo_search(self.pulp,
                                             data={
                                                 "criteria": {
                                                     "type_ids":
                                                     ["puppet_module"],
                                                     "filters": {
                                                         "association": {
                                                             "unit_id":
                                                             unit_id
                                                         }
                                                     }
                                                 }
                                             })
     self.assertPulp(code=200)
     result_new = Association.from_response(response)
     #check that there is only one module with this id
     self.assertTrue(len(result_new) == 1)
     #check that the search inside and outside metadata is consistent
     self.assertIn(
         Association(data={'unit_id': unit_id},
                     required_data_keys=['unit_id'],
                     relevant_data_keys=['unit_id']), result_new)
 def test_04_check_that_one_iso(self):
     # check that there is precisly one module
     dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id)
     self.assertEqual(dest_repo2.data["content_unit_counts"]["iso"], 1)
     # check that one exact module copied i.e. perform the search by modules name
     response = self.dest_repo2.within_repo_search(
         self.pulp, data={"criteria": {"type_ids": ["iso"], "filters": {"unit": {"name": "test.iso"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # this means that only one module found with that name
     self.assertTrue(len(result) == 1)
예제 #11
0
 def test_04_check_that_one_module(self):
     # check that there is precisly one module
     dest_repo2 = Repo.get(self.pulp, self.dest_repo2.id)
     self.assertEqual(dest_repo2.data['content_unit_counts']['puppet_module'], 1)
     # check that one exact module copied i.e. perform the search by modules name
     response = self.dest_repo2.within_repo_search(
         self.pulp,
         data={"criteria": {"type_ids": ["puppet_module"], "filters": {"unit": {"name": "tomcat7_rhel"}}}}
     )
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # this means that only one module found with that name
     self.assertTrue(len(result) == 1)
 def test_03_search_invalid_modules(self):
     response = self.repo.within_repo_search(self.pulp,
                                             data={
                                                 "criteria": {
                                                     "type_ids":
                                                     ["puppet_module"],
                                                     "filters": {
                                                         "unit": {
                                                             "name": "yum"
                                                         }
                                                     }
                                                 }
                                             })
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
예제 #13
0
 def test_06_check_iso_was_unassociated(self):
     #perform a search within the repo
     response = self.dest_repo1.within_repo_search(
         self.pulp,
         data={
             "criteria": {
                 "type_ids": ["iso"],
                 "filters": {
                     "unit": {
                         "name": "test.iso"
                     }
                 }
             }
         })
     self.assertPulp(code=200)
     result = Association.from_response(response)
     self.assertTrue(result == [])
 def test_01_search_modules_within_metadata(self):
     response = self.repo.within_repo_search(self.pulp,
                                             data={
                                                 "criteria": {
                                                     "type_ids":
                                                     ["puppet_module"],
                                                     "filters": {
                                                         "unit": {
                                                             "name":
                                                             "tomcat"
                                                         }
                                                     }
                                                 }
                                             })
     self.assertPulp(code=200)
     result = Association.from_response(response)
     # check that filter works properly and in the result there are only modules with name 'tomcat'
     for i in range(0, len(result)):
         self.assertEqual('tomcat', result[i].data['metadata']['name'])
예제 #15
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)