def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_FEED_URL body['distributors'] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml distributor = repo['distributors'][0] client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) path = urljoin('/pulp/repos/', distributor['config']['relative_url']) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')
def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() if check_issue_2387(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2387') if check_issue_2277(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2277') cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_SIGNED_FEED_URL body['distributors'] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml utils.publish_repo(cls.cfg, repo) path = urljoin( '/pulp/repos/', repo['distributors'][0]['config']['relative_url'] ) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')
def setUpClass(cls): """Upload an erratum to a repo, publish, and download the erratum. Do the following: 1. Create an RPM repository with a distributor. 2. Upload an erratum to the repository. 3. Publish the repository. 4. Fetch the repository's ``updateinfo.xml`` file. """ super(UploadErratumTestCase, cls).setUpClass() if check_issue_2277(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/2277') cls.erratum = gen_erratum() # Create an RPM repository with a feed and distributor. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['importer_config']['feed'] = RPM_SIGNED_FEED_URL body['distributors'] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) # Sync content into the repository, and give it an erratum. utils.sync_repo(cls.cfg, repo['_href']) utils.upload_import_erratum(cls.cfg, cls.erratum, repo['_href']) repo = client.get(repo['_href'], params={'details': True}) # Publish the repository, and fetch and parse updateinfo.xml distributor = repo['distributors'][0] client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) path = urljoin('/pulp/repos/', distributor['config']['relative_url']) cls.updateinfo = get_repomd_xml(cls.cfg, path, 'updateinfo')
def setUpClass(cls): """Create an RPM repository, upload errata, and publish the repository. More specifically, do the following: 1. Create an RPM repository. 2. Add a YUM distributor. 3. Generate a pair of errata. Upload them to Pulp and import them into the repository. 4. Publish the repository. Fetch the ``updateinfo.xml`` file from the distributor (via ``repomd.xml``), and parse it. """ super(UpdateInfoTestCase, cls).setUpClass() cls.errata = { 'import_no_pkglist': _gen_errata_no_pkglist(), 'import_typical': _gen_errata_typical(), } cls.tasks = {} # {'import_no_pkglist': (…), 'import_typical': (…)} # Create a repository and add a yum distributor. client = api.Client(cls.cfg, api.json_handler) repo = client.post(REPOSITORY_PATH, gen_repo()) cls.resources.add(repo['_href']) distributor = client.post( urljoin(repo['_href'], 'distributors/'), gen_distributor(), ) # Import errata into our repository. Publish the repository. for key, erratum in cls.errata.items(): report = utils.upload_import_erratum( cls.cfg, erratum, repo['_href'], ) cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report)) client.post( urljoin(repo['_href'], 'actions/publish/'), {'id': distributor['id']}, ) # Fetch and parse updateinfo.xml (or updateinfo.xml.gz), via repomd.xml cls.root_element = get_repomd_xml( cls.cfg, urljoin('/pulp/repos/', distributor['config']['relative_url']), 'updateinfo' )
def test_post(self): """Assert the function makes an HTTP POST request.""" with mock.patch.object(api, 'Client') as client: # post() is called twice, first to start a content upload and # second to import and upload. In both cases, a dict is returned. # Our dict mocks the first case, and just happens to work in the # second case too. client.return_value.post.return_value = { '_href': 'foo', 'upload_id': 'bar', } response = utils.upload_import_erratum( mock.Mock(), # server_config {'id': 'abc123'}, # erratum 'http://example.com', # repo_href ) self.assertIs(response, client.return_value.post.return_value)
def setUpClass(cls): """Create, populate and publish a repository. More specifically, do the following: 1. Create an RPM repository with a distributor. 2. Populate the repository with an RPM and two errata, where one erratum references the RPM, and the other does not. 3. Publish the repository Fetch and parse its ``updateinfo.xml`` file. """ super(UpdateInfoTestCase, cls).setUpClass() if check_issue_3104(cls.cfg): raise unittest.SkipTest('https://pulp.plan.io/issues/3104') cls.errata = {key: _gen_errata() for key in ('full', 'partial')} del cls.errata['partial']['pkglist'] cls.tasks = {} # Create a repo. client = api.Client(cls.cfg, api.json_handler) body = gen_repo() body['distributors'] = [gen_distributor()] repo = client.post(REPOSITORY_PATH, body) cls.resources.add(repo['_href']) try: # Populate and publish the repo. repo = client.get(repo['_href'], params={'details': True}) unit = utils.http_get(RPM_UNSIGNED_URL) utils.upload_import_unit(cls.cfg, unit, {'unit_type_id': 'rpm'}, repo) for key, erratum in cls.errata.items(): report = utils.upload_import_erratum(cls.cfg, erratum, repo['_href']) cls.tasks[key] = tuple(api.poll_spawned_tasks(cls.cfg, report)) utils.publish_repo(cls.cfg, repo) # Fetch and parse updateinfo.xml. cls.updates_element = (get_repodata(cls.cfg, repo['distributors'][0], 'updateinfo')) except: # noqa:E722 cls.tearDownClass() raise