def test_dict(self): report = SummaryReport() report.errors.append(NodeError(1, A=1, B=2)) report.errors.append(NodeError(2, A=10, B=20)) report.sources.total_passes = 1 report.sources.total_sources = 10 details = DownloadDetails() details.total_succeeded = 98 details.total_failed = 2 report.sources.downloads['content-world'] = details details = DownloadDetails() details.total_succeeded = 999999 details.total_failed = 0 report.sources.downloads['content-galaxy'] = details # test d = report.dict() # validation expected = { 'sources': { 'downloads': { 'content-world': {'total_failed': 2, 'total_succeeded': 98}, 'content-galaxy': {'total_failed': 0, 'total_succeeded': 999999} }, 'total_sources': 10 }, 'errors': [ {'details': {'A': 1, 'B': 2}, 'error_id': 1}, {'details': {'A': 10, 'B': 20}, 'error_id': 2} ] } self.assertEqual(d, expected)
def test_dict(self): report = SummaryReport() report.errors.append(NodeError(1, A=1, B=2)) report.errors.append(NodeError(2, A=10, B=20)) report.sources.total_passes = 1 report.sources.total_sources = 10 details = DownloadDetails() details.total_succeeded = 98 details.total_failed = 2 report.sources.downloads['content-world'] = details details = DownloadDetails() details.total_succeeded = 999999 details.total_failed = 0 report.sources.downloads['content-galaxy'] = details # test d = report.dict() # validation expected = { 'sources': { 'downloads': { 'content-world': { 'total_failed': 2, 'total_succeeded': 98 }, 'content-galaxy': { 'total_failed': 0, 'total_succeeded': 999999 } }, 'total_passes': 1, 'total_sources': 10 }, 'errors': [{ 'details': { 'A': 1, 'B': 2 }, 'error_id': 1 }, { 'details': { 'A': 10, 'B': 20 }, 'error_id': 2 }] } self.assertEqual(d, expected)
def sync_repo(self, repo, conduit, config): """ Synchronize the content of the specified repository. The implementation is delegated to the strategy object which is selected based on the 'strategy' option passed specified in the configuration. :param repo: A repository object. :type repo: pulp.plugins.model.Repository :param conduit: Provides access to relevant Pulp functionality. :param config: pulp.server.conduits.repo_sync.RepoSyncConduit :return: A report describing the result. :rtype: pulp.server.plugins.model.SyncReport """ warnings.warn(TASK_DEPRECATION_WARNING, NodeDeprecationWarning) summary_report = SummaryReport() downloader = None try: downloader = self._downloader(config) strategy_name = config.get(constants.STRATEGY_KEYWORD, constants.DEFAULT_STRATEGY) progress_report = RepositoryProgress(repo.id, ProgressListener(conduit)) request = Request(self.cancel_event, conduit=conduit, config=config, downloader=downloader, progress=progress_report, summary=summary_report, repo=repo) strategy = find_strategy(strategy_name)() strategy.synchronize(request) except Exception, e: summary_report.errors.append(CaughtException(e, repo.id))
def test__init__(self): # test report = SummaryReport() # validation self.assertTrue(isinstance(report.errors, ErrorList)) self.assertTrue(isinstance(report.sources, DownloadReport))
def request(self, cancel_on=0): conduit = TestConduit() progress = RepositoryProgress(REPO_ID, ProgressListener(conduit)) summary = SummaryReport() request = TestRequest(cancel_on=cancel_on, importer=TestImporter(), conduit=conduit, config={}, downloader=Mock(), progress=progress, summary=summary, repo=TestRepo(REPO_ID, self.tmp_dir)) return request
def request(self, cancel_on=0): conduit = TestConduit() progress = RepositoryProgress(REPO_ID, ProgressListener(conduit)) summary = SummaryReport() cancel_event = CancelEvent(cancel_on) request = strategies.Request( cancel_event, conduit=conduit, config={}, downloader=Mock(), progress=progress, summary=summary, repo=TestRepo(REPO_ID, self.tmp_dir) ) return request