def test_get_other_repositories(self): # Setup repos = [ { 'repo_id': 'matching', 'notes': {pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_DOCKER, }, 'distributors': [ {'id': constants.CLI_EXPORT_DISTRIBUTOR_ID}, {'id': constants.CLI_WEB_DISTRIBUTOR_ID} ] }, { 'repo_id': 'non-rpm-repo-1', 'notes': {} } ] self.context.server.repo.repositories.return_value.response_body = repos # Test command = ListDockerRepositoriesCommand(self.context) repos = command.get_other_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['repo_id'], 'non-rpm-repo-1')
def test_get_repositories(self): # Setup repos = [ { 'id': 'matching', 'notes': {pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_DOCKER, }, 'importers': [ {'config': {}} ], 'distributors': [ {'id': constants.CLI_EXPORT_DISTRIBUTOR_ID}, {'id': constants.CLI_WEB_DISTRIBUTOR_ID} ] }, {'id': 'non-rpm-repo', 'notes': {}} ] self.context.server.repo.repositories.return_value.response_body = repos # Test command = ListDockerRepositoriesCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['id'], 'matching') # Make sure the export distributor was removed self.assertEqual(len(repos[0]['distributors']), 1) self.assertEqual(repos[0]['distributors'][0]['id'], constants.CLI_EXPORT_DISTRIBUTOR_ID)
def test_get_repositories_no_details(self): # Setup repos = [ { 'id': 'foo', 'display_name': 'bar', 'notes': {pulp_constants.REPO_NOTE_TYPE_KEY: constants.REPO_NOTE_DOCKER, } } ] self.context.server.repo.repositories.return_value.response_body = repos # Test command = ListDockerRepositoriesCommand(self.context) repos = command.get_repositories({}) # Verify self.assertEqual(1, len(repos)) self.assertEqual(repos[0]['id'], 'foo') self.assertTrue('importers' not in repos[0]) self.assertTrue('distributors' not in repos[0])
def add_repo_section(context, parent_section): """ add a repo section to the docker section :type context: pulp.client.extensions.core.ClientContext :param parent_section: section of the CLI to which the repo section should be added :type parent_section: pulp.client.extensions.extensions.PulpCliSection """ repo_section = parent_section.create_subsection(SECTION_REPO, DESC_REPO) repo_section.add_command(CreateDockerRepositoryCommand(context)) repo_section.add_command(cudl.DeleteRepositoryCommand(context)) repo_section.add_command(UpdateDockerRepositoryCommand(context)) repo_section.add_command(ListDockerRepositoriesCommand(context)) add_search_section(context, repo_section) add_copy_section(context, repo_section) add_remove_section(context, repo_section) return repo_section
def test_get_all_repos_caches_results(self): command = ListDockerRepositoriesCommand(self.context) command.all_repos_cache = 'foo' result = command._all_repos({'bar': 'baz'}) self.assertFalse(self.context.server.repo.repositories.called) self.assertEquals('foo', result)
def test_get_all_repos(self): self.context.server.repo.repositories.return_value.response_body = 'foo' command = ListDockerRepositoriesCommand(self.context) result = command._all_repos({'bar': 'baz'}) self.context.server.repo.repositories.assert_called_once_with({'bar': 'baz'}) self.assertEquals('foo', result)