class TestRemoveBulk(unittest.TestCase): def setUp(self): self.api = OrphanContentAPI(mock.MagicMock()) def test_spec_not_iterable(self): self.assertRaises(TypeError, self.api.remove_bulk, 123) def test_members_not_dicts(self): self.assertRaises(TypeError, self.api.remove_bulk, ['abc', 'def']) def test_dicts_missing_keys(self): self.assertRaises(ValueError, self.api.remove_bulk, [{}, {}]) def test_dicts_have_extra_keys(self): self.assertRaises(ValueError, self.api.remove_bulk, [{'content_type_id' : 'foo', 'unit_id' : 'bar', 'x' : 'y'}]) def test_success(self): specs = [{'content_type_id' : 'foo', 'unit_id' : 'bar'}] ret = self.api.remove_bulk(specs) body = json.dumps(specs) self.api.server.POST.assert_called_once_with(self.api.DELETE_BULK_PATH, body) self.assertEqual(ret, self.api.server.POST.return_value)
class TestRemoveBulk(unittest.TestCase): def setUp(self): self.api = OrphanContentAPI(mock.MagicMock()) def test_spec_not_iterable(self): self.assertRaises(TypeError, self.api.remove_bulk, 123) def test_members_not_dicts(self): self.assertRaises(TypeError, self.api.remove_bulk, ['abc', 'def']) def test_dicts_missing_keys(self): self.assertRaises(ValueError, self.api.remove_bulk, [{}, {}]) def test_dicts_have_extra_keys(self): self.assertRaises(ValueError, self.api.remove_bulk, [{ 'content_type_id': 'foo', 'unit_id': 'bar', 'x': 'y' }]) def test_success(self): specs = [{'content_type_id': 'foo', 'unit_id': 'bar'}] ret = self.api.remove_bulk(specs) body = json.dumps(specs) self.api.server.POST.assert_called_once_with(self.api.DELETE_BULK_PATH, body) self.assertEqual(ret, self.api.server.POST.return_value)
def __init__(self, pulp_connection): """ @type: pulp_connection: pulp.bindings.server.PulpConnection """ # Please keep the following in alphabetical order to ease reading self.actions = ActionsAPI(pulp_connection) self.bind = consumer.BindingsAPI(pulp_connection) self.bindings = consumer.BindingSearchAPI(pulp_connection) self.profile = consumer.ProfilesAPI(pulp_connection) self.consumer = consumer.ConsumerAPI(pulp_connection) self.consumer_content = consumer.ConsumerContentAPI(pulp_connection) self.consumer_content_schedules = consumer.ConsumerContentSchedulesAPI( pulp_connection) self.consumer_group = consumer_groups.ConsumerGroupAPI(pulp_connection) self.consumer_group_search = consumer_groups.ConsumerGroupSearchAPI( pulp_connection) self.consumer_group_actions = consumer_groups.ConsumerGroupActionAPI( pulp_connection) self.consumer_group_bind = consumer_groups.ConsumerGroupBindAPI( pulp_connection) self.consumer_group_content = consumer_groups.ConsumerGroupContentAPI( pulp_connection) self.consumer_history = consumer.ConsumerHistoryAPI(pulp_connection) self.consumer_search = consumer.ConsumerSearchAPI(pulp_connection) self.content_orphan = OrphanContentAPI(pulp_connection) self.content_source = ContentSourceAPI(pulp_connection) self.content_catalog = ContentCatalogAPI(pulp_connection) self.event_listener = EventListenerAPI(pulp_connection) self.permission = auth.PermissionAPI(pulp_connection) self.repo = repository.RepositoryAPI(pulp_connection) self.repo_actions = repository.RepositoryActionsAPI(pulp_connection) self.repo_distributor = repository.RepositoryDistributorAPI( pulp_connection) self.repo_group = repo_groups.RepoGroupAPI(pulp_connection) self.repo_group_actions = repo_groups.RepoGroupActionAPI( pulp_connection) self.repo_group_distributor = repo_groups.RepoGroupDistributorAPI( pulp_connection) self.repo_group_distributor_search = repo_groups.RepoGroupSearchAPI( pulp_connection) self.repo_group_search = repo_groups.RepoGroupSearchAPI( pulp_connection) self.repo_history = repository.RepositoryHistoryAPI(pulp_connection) self.repo_importer = repository.RepositoryImporterAPI(pulp_connection) self.repo_publish_schedules = repository.RepositoryPublishSchedulesAPI( pulp_connection) self.repo_search = repository.RepositorySearchAPI(pulp_connection) self.repo_sync_schedules = repository.RepositorySyncSchedulesAPI( pulp_connection) self.repo_unit = repository.RepositoryUnitAPI(pulp_connection) self.role = auth.RoleAPI(pulp_connection) self.server_info = ServerInfoAPI(pulp_connection) self.server_status = ServerStatusAPI(pulp_connection) self.tasks = TasksAPI(pulp_connection) self.tasks_search = TaskSearchAPI(pulp_connection) self.uploads = UploadAPI(pulp_connection) self.user = auth.UserAPI(pulp_connection) self.user_search = auth.UserSearchAPI(pulp_connection)
class TestOrphanAPI(unittest.TestCase): def setUp(self): self.api = OrphanContentAPI(mock.MagicMock()) def test_paths(self): self.assertTrue(len(self.api.PATH) > 0) # make sure it's a relative path self.assertFalse(self.api.PATH.startswith('/')) def test_delete_bulk_path(self): self.assertTrue(len(self.api.DELETE_BULK_PATH) > 0) # make sure it's a relative path self.assertFalse(self.api.DELETE_BULK_PATH.startswith('/')) def test_list_orphans(self): ret = self.api.orphans() self.api.server.GET.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.GET.return_value) def test_list_orphans_by_type(self): ret = self.api.orphans_by_type('rpm') self.api.server.GET.assert_called_once_with(self.api.PATH + 'rpm/') self.assertEqual(ret, self.api.server.GET.return_value) def test_remove(self): ret = self.api.remove('rpm', 'foo') self.api.server.DELETE.assert_called_once_with(self.api.PATH + 'rpm/foo/') self.assertEqual(ret, self.api.server.DELETE.return_value) def test_remove_by_type(self): ret = self.api.remove_by_type('rpm') self.api.server.DELETE.assert_called_once_with(self.api.PATH + 'rpm/') self.assertEqual(ret, self.api.server.DELETE.return_value) def test_remove_all(self): ret = self.api.remove_all() self.api.server.DELETE.assert_called_once_with(self.api.PATH) self.assertEqual(ret, self.api.server.DELETE.return_value)
def __init__(self, pulp_connection): """ @type: pulp_connection: pulp.bindings.server.PulpConnection """ # Please keep the following in alphabetical order to ease reading self.actions = ActionsAPI(pulp_connection) self.bind = BindingsAPI(pulp_connection) self.bindings = BindingSearchAPI(pulp_connection) self.profile = ProfilesAPI(pulp_connection) self.consumer = ConsumerAPI(pulp_connection) self.consumer_content = ConsumerContentAPI(pulp_connection) self.consumer_content_schedules = ConsumerContentSchedulesAPI( pulp_connection) self.consumer_group = ConsumerGroupAPI(pulp_connection) self.consumer_group_search = ConsumerGroupSearchAPI(pulp_connection) self.consumer_group_actions = ConsumerGroupActionAPI(pulp_connection) self.consumer_group_bind = ConsumerGroupBindAPI(pulp_connection) self.consumer_group_content = ConsumerGroupContentAPI(pulp_connection) self.consumer_history = ConsumerHistoryAPI(pulp_connection) self.consumer_search = ConsumerSearchAPI(pulp_connection) self.content_orphan = OrphanContentAPI(pulp_connection) self.event_listener = EventListenerAPI(pulp_connection) self.permission = PermissionAPI(pulp_connection) self.repo = RepositoryAPI(pulp_connection) self.repo_actions = RepositoryActionsAPI(pulp_connection) self.repo_distributor = RepositoryDistributorAPI(pulp_connection) self.repo_group = RepoGroupAPI(pulp_connection) self.repo_group_actions = RepoGroupActionAPI(pulp_connection) self.repo_group_distributor = RepoGroupDistributorAPI(pulp_connection) self.repo_group_distributor_search = RepoGroupSearchAPI( pulp_connection) self.repo_group_search = RepoGroupSearchAPI(pulp_connection) self.repo_history = RepositoryHistoryAPI(pulp_connection) self.repo_importer = RepositoryImporterAPI(pulp_connection) self.repo_publish_schedules = RepositoryPublishSchedulesAPI( pulp_connection) self.repo_search = RepositorySearchAPI(pulp_connection) self.repo_sync_schedules = RepositorySyncSchedulesAPI(pulp_connection) self.repo_unit = RepositoryUnitAPI(pulp_connection) self.role = RoleAPI(pulp_connection) self.server_info = ServerInfoAPI(pulp_connection) self.tasks = TasksAPI(pulp_connection) self.tasks_search = TaskSearchAPI(pulp_connection) self.uploads = UploadAPI(pulp_connection) self.user = UserAPI(pulp_connection) self.user_search = UserSearchAPI(pulp_connection)
def setUp(self): self.api = OrphanContentAPI(mock.MagicMock())