diff --git a/plugins/pulp_python/plugins/distributors/steps.py b/plugins/pulp_python/plugins/distributors/steps.py index a511f64e..b5c0a6e8 100644 --- a/plugins/pulp_python/plugins/distributors/steps.py +++ b/plugins/pulp_python/plugins/distributors/steps.py @@ -1,6 +1,6 @@ +from gettext import gettext as _ import logging import os -from gettext import gettext as _ from xml.etree import cElementTree as ElementTree from pulp.plugins.util.publish_step import AtomicDirectoryPublishStep, PluginStep diff --git a/plugins/pulp_python/plugins/distributors/web.py b/plugins/pulp_python/plugins/distributors/web.py index 92bb8135..cb61c09b 100644 --- a/plugins/pulp_python/plugins/distributors/web.py +++ b/plugins/pulp_python/plugins/distributors/web.py @@ -1,7 +1,7 @@ import copy +from gettext import gettext as _ import logging import shutil -from gettext import gettext as _ from pulp.common.config import read_json_config from pulp.plugins.distributor import Distributor diff --git a/plugins/pulp_python/plugins/importers/importer.py b/plugins/pulp_python/plugins/importers/importer.py index c8f7c2f4..38a00985 100644 --- a/plugins/pulp_python/plugins/importers/importer.py +++ b/plugins/pulp_python/plugins/importers/importer.py @@ -1,6 +1,6 @@ +from gettext import gettext as _ import shutil import tempfile -from gettext import gettext as _ from pulp.plugins.importer import Importer from pulp.server.db.model import criteria diff --git a/plugins/pulp_python/plugins/importers/sync.py b/plugins/pulp_python/plugins/importers/sync.py index 9747dcae..f4bc701b 100644 --- a/plugins/pulp_python/plugins/importers/sync.py +++ b/plugins/pulp_python/plugins/importers/sync.py @@ -1,12 +1,12 @@ """ This module contains the necessary means for a necessary means for syncing packages from PyPI. """ +from cStringIO import StringIO +from gettext import gettext as _ import json import logging import os import shutil -from cStringIO import StringIO -from gettext import gettext as _ from urlparse import urljoin from nectar import request @@ -151,8 +151,8 @@ def download_succeeded(self, report): package = models.Package.from_archive(report.destination) package.init_unit(self.conduit) - # Move the package into its proper place - shutil.move(report.destination, package.storage_path) + # Copy the package from working directory into its proper place + shutil.copy(report.destination, package.storage_path) package.save_unit(self.conduit) diff --git a/plugins/pulp_python/plugins/models.py b/plugins/pulp_python/plugins/models.py index 0c8d0dcc..83eadb43 100644 --- a/plugins/pulp_python/plugins/models.py +++ b/plugins/pulp_python/plugins/models.py @@ -1,7 +1,7 @@ +from gettext import gettext as _ import hashlib import re import tarfile -from gettext import gettext as _ from pulp_python.common import constants diff --git a/plugins/test/unit/plugins/distributors/test_steps.py b/plugins/test/unit/plugins/distributors/test_steps.py index cc70317f..3082e1b2 100644 --- a/plugins/test/unit/plugins/distributors/test_steps.py +++ b/plugins/test/unit/plugins/distributors/test_steps.py @@ -1,10 +1,9 @@ """ This module contains tests for the pulp_python.plugins.distributors.steps module. """ +from gettext import gettext as _ import os import unittest - -from gettext import gettext as _ from xml.etree import cElementTree as ElementTree import mock diff --git a/plugins/test/unit/plugins/importers/test_importer.py b/plugins/test/unit/plugins/importers/test_importer.py index ce7ab794..9a2a2e91 100644 --- a/plugins/test/unit/plugins/importers/test_importer.py +++ b/plugins/test/unit/plugins/importers/test_importer.py @@ -1,8 +1,8 @@ """ Contains tests for pulp_python.plugins.importers.importer. """ -import unittest from gettext import gettext as _ +import unittest import mock diff --git a/plugins/test/unit/plugins/importers/test_sync.py b/plugins/test/unit/plugins/importers/test_sync.py index 768fde0a..66d10682 100644 --- a/plugins/test/unit/plugins/importers/test_sync.py +++ b/plugins/test/unit/plugins/importers/test_sync.py @@ -1,11 +1,11 @@ """ This module contains tests for the pulp_python.plugins.importers.sync module. """ +from cStringIO import StringIO +from gettext import gettext as _ import os import types import unittest -from cStringIO import StringIO -from gettext import gettext as _ import mock from pulp.server.db.model import criteria @@ -683,8 +683,8 @@ class TestDownloadPackagesStep(unittest.TestCase): @mock.patch('pulp_python.plugins.importers.sync.models.Package.save_unit') @mock.patch('pulp_python.plugins.importers.sync.DownloadPackagesStep.download_failed') @mock.patch('pulp_python.plugins.importers.sync.publish_step.DownloadStep.download_succeeded') - @mock.patch('pulp_python.plugins.importers.sync.shutil.move') - def test_download_succeeded_checksum_bad(self, move, super_download_succeeded, + @mock.patch('pulp_python.plugins.importers.sync.shutil.copy') + def test_download_succeeded_checksum_bad(self, copy, super_download_succeeded, download_failed, save_unit, checksum): """ Test the download_succeeded() method when the checksum of the downloaded package is @@ -709,16 +709,16 @@ def test_download_succeeded_checksum_bad(self, move, super_download_succeeded, download_failed.assert_called_once_with(report) # Make sure the checksum was calculated with the correct data checksum.assert_called_once_with(report.destination, 'md5') - # move and save_unit should not have been called since the download failed - self.assertEqual(move.call_count, 0) + # copy and save_unit should not have been called since the download failed + self.assertEqual(copy.call_count, 0) self.assertEqual(save_unit.call_count, 0) @mock.patch('pulp_python.plugins.importers.sync.models.Package.checksum') @mock.patch('pulp_python.plugins.importers.sync.models.Package.from_archive') @mock.patch('pulp_python.plugins.importers.sync.DownloadPackagesStep.download_failed') @mock.patch('pulp_python.plugins.importers.sync.publish_step.DownloadStep.download_succeeded') - @mock.patch('pulp_python.plugins.importers.sync.shutil.move') - def test_download_succeeded_checksum_good(self, move, super_download_succeeded, download_failed, + @mock.patch('pulp_python.plugins.importers.sync.shutil.copy') + def test_download_succeeded_checksum_good(self, copy, super_download_succeeded, download_failed, from_archive, checksum): """ Test the download_succeeded() method when the checksum of the downloaded package is correct. @@ -740,8 +740,8 @@ def test_download_succeeded_checksum_good(self, move, super_download_succeeded, # The Package's init_unit should have been handed the conduit package = from_archive.return_value package.init_unit.assert_called_once_with(conduit) - # The unit should have been moved to the storage path - move.assert_called_once_with(report.destination, package.storage_path) + # The unit should have been copied to the storage path + copy.assert_called_once_with(report.destination, package.storage_path) # The unit should have been saved to the DB package.save_unit.assert_called_once_with(conduit) # The superclass success method should have been called. diff --git a/plugins/test/unit/plugins/test_models.py b/plugins/test/unit/plugins/test_models.py index f859a944..260fd6e9 100644 --- a/plugins/test/unit/plugins/test_models.py +++ b/plugins/test/unit/plugins/test_models.py @@ -1,11 +1,11 @@ """ This modules contains tests for pulp_python.plugins.models. """ +from gettext import gettext as _ import hashlib import re import tarfile import unittest -from gettext import gettext as _ import mock