Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Minor update for docker remove test cases
Browse files Browse the repository at this point in the history
Minor update for docker remove test cases. Tweak docstrings and remove
redundat variable.
  • Loading branch information
koliveir authored and bherrin3 committed Aug 1, 2019
1 parent 086b660 commit 73f0521
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions docs/tests.rst
Expand Up @@ -13,6 +13,7 @@ Location: :doc:`/index` → :doc:`/tests`
tests/pulp_2_tests.tests.docker.api_v2.test_copy
tests/pulp_2_tests.tests.docker.api_v2.test_crud
tests/pulp_2_tests.tests.docker.api_v2.test_duplicate_uploads
tests/pulp_2_tests.tests.docker.api_v2.test_remove
tests/pulp_2_tests.tests.docker.api_v2.test_sync
tests/pulp_2_tests.tests.docker.api_v2.test_sync_publish
tests/pulp_2_tests.tests.docker.api_v2.test_tags
Expand Down
6 changes: 6 additions & 0 deletions docs/tests/pulp_2_tests.tests.docker.api_v2.test_remove.rst
@@ -0,0 +1,6 @@
`pulp_2_tests.tests.docker.api_v2.test_remove`
==============================================

Location: :doc:`/index` → :doc:`/tests` → :doc:`/tests/pulp_2_tests.tests.docker.api_v2.test_remove`

.. automodule:: pulp_2_tests.tests.docker.api_v2.test_remove
33 changes: 13 additions & 20 deletions pulp_2_tests/tests/docker/api_v2/test_remove.py
Expand Up @@ -12,9 +12,7 @@
from pulp_2_tests.tests.docker.utils import get_upstream_name

# Dummy Data - Need to datamine a DOCKER repo
DOCKER_REMOVE = {
'INITIAL': {'MANIFEST': 10, 'MANIFEST_LIST': 2, 'BLOB': 8, 'TAG': 13},
}
DOCKER_REMOVE = {'INITIAL': {'MANIFEST': 10, 'MANIFEST_LIST': 2, 'BLOB': 8, 'TAG': 13}}


class RemoveV2ContentTestCase(unittest.TestCase):
Expand Down Expand Up @@ -47,47 +45,42 @@ def setUpClass(cls):

def setUp(self):
"""Set variables used by each test case."""
self.body = gen_repo(
body = gen_repo(
importer_config={
'enable_v1': False,
'enable_v2': True,
'feed': DOCKER_V2_FEED_URL,
'upstream_name': get_upstream_name(self.cfg),
}
)
self.repo = self.client.post(REPOSITORY_PATH, self.body)
self.repo = self.client.post(REPOSITORY_PATH, body)
self.addCleanup(self.client.delete, self.repo['_href'])
sync_repo(self.cfg, self.repo)

def get_docker_units(self, repo, unit_type):
"""Sync docker repo and move tags."""
"""Return docker units filtered by type."""
# Get unit counts
units = search_units(
self.cfg, repo, {
'type_ids': [unit_type],
'filters': {
'unit': {}
},
})
return units
return search_units(
self.cfg, repo, {'type_ids': [unit_type], 'filters': {'unit': {}}}
)

def delete_docker_units(self, repo, units):
"""Sync docker repo and move tags."""
"""Delete docker units."""
for unit in units:
criteria = {
'type_ids': [
'docker_tag',
'docker_manifest_list',
'docker_manifest',
'docker_blob'
'docker_blob',
],
'filters': {'unit': {'_id': unit['unit_id']}},
# "filters": {"unit": {"_id": {"$in": units}}}
}
self.client.post(urljoin(repo['_href'], 'actions/unassociate/'), {
'source_repo_id': repo['id'],
'criteria': criteria,
})
self.client.post(
urljoin(repo['_href'], 'actions/unassociate/'),
{'source_repo_id': repo['id'], 'criteria': criteria},
)

def test_01_remove_tag_list_all(self):
"""Sync docker repo and remove all tags."""
Expand Down

0 comments on commit 73f0521

Please sign in to comment.