-
Notifications
You must be signed in to change notification settings - Fork 80
Upload support #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ htmlcov/ | |
| .cache | ||
| nosetests.xml | ||
| coverage.xml | ||
| cover/ | ||
|
|
||
| # Translations | ||
| *.mo | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,19 @@ | ||
|
|
||
| REPOSITORY_TYPE_ID = 'python_repository' | ||
| PACKAGE_TYPE_ID = 'python_package' | ||
| REPO_NOTE_PYTHON = 'PYTHON' | ||
|
|
||
| WEB_IMPORTER_TYPE_ID = 'python_web_importer' | ||
| WEB_DISTRIBUTOR_TYPE_ID = 'python_web_distributor' | ||
|
|
||
| CLI_WEB_DISTRIBUTOR_ID = 'python_web_distributor_name_cli' | ||
| IMPORTER_TYPE_ID = 'python_importer' | ||
| DISTRIBUTOR_TYPE_ID = 'python_distributor' | ||
|
|
||
| IMPORTER_CONFIG_KEY_BRANCHES = 'branches' | ||
| CLI_DISTRIBUTOR_ID = 'cli_python_distributor' | ||
|
|
||
| DISTRIBUTOR_CONFIG_FILE_NAME = 'server/plugins.conf.d/python_distributor.json' | ||
|
|
||
| # Config keys for the distributor plugin conf | ||
| CONFIG_KEY_PYTHON_PUBLISH_DIRECTORY = 'python_publish_directory' | ||
| CONFIG_VALUE_PYTHON_PUBLISH_DIRECTORY = '/var/lib/pulp/published/python' | ||
| CONFIG_KEY_PUBLISH_DIRECTORY = 'python_publish_directory' | ||
| CONFIG_VALUE_PUBLISH_DIRECTORY = '/var/lib/pulp/published/python' | ||
|
|
||
| # STEP_ID | ||
| PUBLISH_STEP_WEB_PUBLISHER = 'python_publish_step_web' | ||
| PUBLISH_STEP_PUBLISHER = 'python_publish_step' | ||
| PUBLISH_STEP_CONTENT = 'python_publish_content' | ||
| PUBLISH_STEP_METADATA = 'python_publish_metadata' | ||
| PUBLISH_STEP_OVER_HTTP = 'python_publish_over_http' |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from pulp.client.commands.repo import upload | ||
|
|
||
| from pulp_python.common import constants | ||
|
|
||
|
|
||
| class UploadPackageCommand(upload.UploadCommand): | ||
| """ | ||
| The command used to upload Python packages. | ||
| """ | ||
| def determine_type_id(self, filename, **kwargs): | ||
| """ | ||
| Return pulp_python.common.constants.PACKAGE_TYPE_ID. | ||
|
|
||
| :param filename: Unused | ||
| :type filename: basestring | ||
| :param kwargs: Unused | ||
| :type kwargs: dict | ||
| :returns: pulp_python.common.constants.PACKAGE_TYPE_ID | ||
| :rtype: basestring | ||
| """ | ||
| return constants.PACKAGE_TYPE_ID | ||
|
|
||
| def generate_unit_key(self, *args, **kwargs): | ||
| """ | ||
| We don't need to generate the unit key client-side, but the superclass requires us to define | ||
| this method. It returns the empty dictionary. | ||
|
|
||
| :param args: Unused | ||
| :type args: list | ||
| :param kwargs: Unused | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. kwargs that we don't use?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
| :type kwargs: dict | ||
| :returns: An empty dictionary | ||
| :rtype: dict | ||
| """ | ||
| return {} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| """ | ||
| This module contains tests for the pulp_python.extensions.admin.upload module. | ||
| """ | ||
| import unittest | ||
|
|
||
| import mock | ||
|
|
||
| from pulp_python.common import constants | ||
| from pulp_python.extensions.admin import upload | ||
|
|
||
|
|
||
| @mock.patch('pulp.client.upload.manager.UploadManager.init_with_defaults', mock.MagicMock()) | ||
| class TestUploadPackageCommand(unittest.TestCase): | ||
| """ | ||
| This class contains tests for the UploadPackageCommand class. | ||
| """ | ||
| def test_determine_type_id(self): | ||
| """ | ||
| Assert that determine_type_id() returns the correct type. | ||
| """ | ||
| command = upload.UploadPackageCommand(mock.MagicMock()) | ||
|
|
||
| type_id = command.determine_type_id('some_file_name', some='kwargs') | ||
|
|
||
| self.assertEqual(type_id, constants.PACKAGE_TYPE_ID) | ||
|
|
||
| def test_generate_unit_key(self): | ||
| """ | ||
| Assert that generate_unit_key() returns the empty dictionary. | ||
| """ | ||
| command = upload.UploadPackageCommand(mock.MagicMock()) | ||
|
|
||
| key = command.generate_unit_key('some', 'args', and_some='kwargs') | ||
|
|
||
| self.assertEqual(key, {}) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args that we don't use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 10/22/2014 04:18 PM, bmbouter wrote:
The Python server-side plugins were intentionally written to avoid
needing the client to pass any metadata, since the uploaded package
already has all the metadata in it. However, the CLI uploader method
signature will pass various things to us like that filename and perhaps
other things (see the superclass). In the CLI code we don't want or care
about any of these args because we are going to just return the empty
dictionary no matter what, but we have to accept the args because we are
going to get them from the CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check