Example #1
0
 def test_dict(self):
     source_id = 's-1'
     url = 'myurl'
     report = RefreshReport(source_id, url)
     report_dict = report.dict()
     self.assertEqual(report_dict['source_id'], source_id)
     self.assertEqual(report_dict['url'], url)
     self.assertFalse(report_dict['succeeded'])
     self.assertEqual(report_dict['added_count'], 0)
     self.assertEqual(report_dict['deleted_count'], 0)
     self.assertEqual(report_dict['errors'], [])
Example #2
0
 def test_dict(self):
     source_id = 's-1'
     url = 'myurl'
     report = RefreshReport(source_id, url)
     report_dict = report.dict()
     self.assertEqual(report_dict['source_id'], source_id)
     self.assertEqual(report_dict['url'], url)
     self.assertFalse(report_dict['succeeded'])
     self.assertEqual(report_dict['added_count'], 0)
     self.assertEqual(report_dict['deleted_count'], 0)
     self.assertEqual(report_dict['errors'], [])
Example #3
0
 def test_dict(self):
     source_id = "s-1"
     url = "myurl"
     report = RefreshReport(source_id, url)
     report_dict = report.dict()
     self.assertEqual(report_dict["source_id"], source_id)
     self.assertEqual(report_dict["url"], url)
     self.assertFalse(report_dict["succeeded"])
     self.assertEqual(report_dict["added_count"], 0)
     self.assertEqual(report_dict["deleted_count"], 0)
     self.assertEqual(report_dict["errors"], [])
Example #4
0
 def test_construction(self):
     source_id = 's-1'
     url = 'myurl'
     report = RefreshReport(source_id, url)
     self.assertEqual(report.source_id, source_id)
     self.assertEqual(report.url, url)
     self.assertFalse(report.succeeded)
     self.assertEqual(report.added_count, 0)
     self.assertEqual(report.deleted_count, 0)
     self.assertEqual(report.errors, [])
Example #5
0
    def refresh(self, force=False):
        """
        Refresh the content catalog using available content sources.

        :param force: Force refresh of content sources with unexpired catalog entries.
        :type force: bool
        :return: A list of refresh reports.
        :rtype: list of: pulp.server.content.sources.model.RefreshReport
        """
        reports = []
        catalog = managers.content_catalog_manager()
        for source_id, source in self.sources.items():
            if force or not catalog.has_entries(source_id):
                try:
                    report = source.refresh()
                    reports.extend(report)
                except Exception, e:
                    log.error('refresh %s, failed: %s', source_id, e)
                    report = RefreshReport(source_id, '')
                    report.errors.append(str(e))
                    reports.append(report)
Example #6
0
 def setUp(self):
     self.conduit = mock.MagicMock()
     self.step = ContentSourcesRefreshStep(self.conduit)
     self.source = ContentSource('foo', {'name': 'foo'})
     self.report = RefreshReport('foo', 'http://foo.com')
     self.report.succeeded = True