pulp_2_tests.tests.rpm.api_v2.test_repomd

Location: Pulp 2 TestsTestspulp_2_tests.tests.rpm.api_v2.test_repomd

Verify the repomd.xml file generated by a YUM distributor.

class pulp_2_tests.tests.rpm.api_v2.test_repomd.FastForwardIntegrityTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Ensure fast-forward publishes use files referenced by repomd.xml.

When Pulp performs an incremental fast-forward publish, it should copy the original repository’s repodata/[…]-primary.xml file to the new repository, and then modify it as needed.

According to Pulp #1088, Pulp does something different: it searches for all files named repodata/[0-9a-zA-Z]*-primary.xml.*, sorts them by mtime, copies the newest one to the new repository and modifies it. This behaviour typically works, because Pulp only creates one […]-primary.xml file in a given repository. However, this behaviour is fragile, and it’s especially likely to fail when third-party tools are used to supplement Pulp’s functionality. What Pulp should do is to consult the old repository’s repomd.xml file to find the […]-primary.xml file.

Do the following:

  1. Create a repository with a yum distributor, sync in some content, and publish it. Verify that […]-primary.xml contains a certain phrase.
  2. Create a second […]-primary.xml file in the published repository, and replace the known phrase with a new phrase. Trigger a full publish, and verify that the known phrase is present, not the new phrase.
  3. Create a second […]-primary.xml file in the published repository, and replace the known phrase with a new phrase. Trigger an incremental publish, and verify that the known phrase is present, not the new phrase.
test_all()

Ensure fast-forward publishes use files referenced by repomd.xml.

class pulp_2_tests.tests.rpm.api_v2.test_repomd.RepoMDTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Tests to ensure repomd.xml can be created and is valid.

classmethod setUpClass()

Create shared class-wide variables.

classmethod tearDownClass()

Clean up class-wide resources.

test_01_set_up()

Create and publish a repo, and fetch and parse its repomd.xml.

test_02_data_elements()

Assert the tree’s “data” elements have correct “type” attributes.

test_02_tag()

Assert the XML tree’s root element has the correct tag.

pulp_2_tests.tests.rpm.api_v2.test_repomd.skip_if(func, var_name, result, *, exc=<class 'unittest.case.SkipTest'>)

Optionally skip a test method, based on a condition.

This decorator checks to see if func(getattr(self, var_name)) equals result. If so, an exception of type exc is raised. Otherwise, nothing happens, and the decorated test method continues as normal. Here’s an example of how to use this method:

>>> import unittest
>>> from pulp_smash.selectors import skip_if
>>> class MyTestCase(unittest.TestCase):
...
...     @classmethod
...     def setUpClass(cls):
...         cls.my_var = False
...
...     @skip_if(bool, 'my_var', False, unittest.SkipTest)
...     def test_01_skips(self):
...         pass
...
...     def test_02_runs(self):
...         type(self).my_var = True
...
...     @skip_if(bool, 'my_var', False, unittest.SkipTest)
...     def test_03_runs(self):
...         pass

If the same exception should be passed each time this method is called, consider using functools.partial:

>>> from functools import partial
>>> from unittest import SkipTest
>>> from pulp_smash.selectors import skip_if
>>> unittest_skip_if = partial(skip_if, exc=SkipTest)
Parameters:
  • var_name – A valid variable name.
  • result – A value to compare to func(getattr(self, var_name)).
  • exc – A class to instantiate and raise as an exception. Its constructor must accept one string argument.