pulp_2_tests.tests.docker.api_v2.test_copy

Location: Pulp 2 TestsTestspulp_2_tests.tests.docker.api_v2.test_copy

Tests for copying docker units between repositories.

class pulp_2_tests.tests.docker.api_v2.test_copy.CopyV2ContentTestCase(methodName='runTest')

Bases: unittest.case.TestCase

Copy data between Docker repositories with schema v2 content.

classmethod setUpClass()

Create class-wide variables.

set_user_metadata(tag, content)

Associate docker tag to user metadata content.

For information on setting user_metadata to tag refer Docker Content Units.

classmethod tearDownClass()

Clean up resources.

test_01_set_up()

Create a repository and populate with with schema v2 content.

test_02_copy_manifest_lists()

Copy manifest lists from one repository to another.

Assert the same number of manifest lists are present in both repositories. This test targets:

test_02_copy_manifests()

Copy manifests from one repository to another.

Assert the same number of manifests are present in both repositories.

test_02_copy_tags()

Copy tags from one repository to another.

Assert the same number of tags are present in both repositories.

This test targets Pulp #3892.

test_02_copy_tags_user_metadata()

Copy tags with user_metadata from one repository to another.

Assert the user metadata associated with a tag is present in both repositories.

Steps:

  1. Add user metadata to the first tag in the source repo.
  2. Copy the tags from one repo to the other.
  3. Verify that the user_metadata is copied to the other repo.

This test targets the following

pulp_2_tests.tests.docker.api_v2.test_copy.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.