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

Commit

Permalink
Pass the old-style repo object to the UploadStep.
Browse files Browse the repository at this point in the history
  • Loading branch information
Randy Barlow committed Feb 9, 2016
1 parent d57aceb commit 5b3bb4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 0 additions & 3 deletions plugins/pulp_docker/plugins/importers/importer.py
Expand Up @@ -4,7 +4,6 @@
from pulp.common.config import read_json_config
from pulp.plugins.importer import Importer
from pulp.server.controllers import repository
from pulp.server.db import model
from pulp.server.db.model.criteria import UnitAssociationCriteria
from pulp.server.managers.repo import unit_association
import pulp.server.managers.factory as manager_factory
Expand Down Expand Up @@ -126,8 +125,6 @@ def upload_unit(self, repo, type_id, unit_key, metadata, file_path, conduit, con
'details': json-serializable object, providing details
:rtype: dict
"""
repo = model.Repository.objects.get_repo_or_missing_resource(repo.id)

upload_step = upload.UploadStep(repo=repo, file_path=file_path, config=config)
upload_step.process_lifecycle()

Expand Down
10 changes: 3 additions & 7 deletions plugins/test/unit/plugins/importers/test_importer.py
Expand Up @@ -91,9 +91,8 @@ class TestUploadUnit(unittest.TestCase):
"""
Assert correct operation of DockerImporter.upload_unit().
"""
@mock.patch('pulp_docker.plugins.importers.importer.model.Repository.objects')
@mock.patch('pulp_docker.plugins.importers.importer.upload.UploadStep')
def test_correct_calls(self, UploadStep, objects):
def test_correct_calls(self, UploadStep):
"""
Assert that upload_unit() builds the UploadStep correctly and calls its process_lifecycle()
method.
Expand All @@ -106,9 +105,8 @@ def test_correct_calls(self, UploadStep, objects):
DockerImporter().upload_unit(repo, constants.IMAGE_TYPE_ID, unit_key,
{}, data.busybox_tar_path, conduit, config)

objects.get_repo_or_missing_resource.assert_called_once_with(repo.id)
UploadStep.assert_called_once_with(repo=objects.get_repo_or_missing_resource.return_value,
file_path=data.busybox_tar_path, config=config)
UploadStep.assert_called_once_with(repo=repo, file_path=data.busybox_tar_path,
config=config)
UploadStep.return_value.process_lifecycle.assert_called_once_with()


Expand Down Expand Up @@ -299,7 +297,6 @@ def test_always_true(self):
self.assertEqual(DockerImporter().validate_config(repo, config), (True, ''))


@mock.patch('pulp_docker.plugins.importers.importer.model.Repository.objects')
class TestRemoveUnits(unittest.TestCase):

# We are under a significant time crunch and don't have time to correct all the tests with this
Expand Down Expand Up @@ -336,7 +333,6 @@ def test_remove_with_tag(self, mock_repo_qs):
self.assertEqual(mock_repo.scratchpad['tags'], [])


@mock.patch('pulp_docker.plugins.importers.importer.model.Repository.objects')
class TestPurgeUnreferencedTags(unittest.TestCase):

def setUp(self):
Expand Down

0 comments on commit 5b3bb4d

Please sign in to comment.