def test_invalid(self, *unused): path = os.path.join(self.tmp_dir, 'other.conf') with open(path, 'w+') as fp: for other in (MISSING_ENABLED, MISSING_TYPE, MISSING_BASE_URL): fp.write(other) sources = ContentSource.load_all(self.tmp_dir) for source_id, source in sources.items(): self.assertFalse(is_valid(source_id, source.descriptor))
def is_valid(self): """ Get whether the content source has a valid descriptor, references a valid cataloger plugin, and can create a nectar downloader. :return: True if valid. :rtype: bool """ try: self.downloader() plugin_id = self.descriptor[constants.TYPE] plugins.get_cataloger_by_id(plugin_id) return is_valid(self.id, self.descriptor) except Exception: return False
def is_valid(self): """ Get whether the content source has a valid descriptor, references a valid cataloger plugin, and can create a nectar downloader. :return: True if valid. :rtype: bool """ try: self.get_cataloger() self.get_downloader() return is_valid(self.id, self.descriptor) except Exception: log.exception('source [%s] not valid', self.id) return False
def test_invalid(self): for s in (MISSING_ENABLED, MISSING_TYPE, MISSING_BASE_URL): fp = StringIO(s) config = Config(fp) for source_id, descriptor in config.items(): self.assertFalse(is_valid(source_id, descriptor))
def test_valid(self): fp = StringIO(VALID) config = Config(fp) for source_id, descriptor in config.items(): self.assertTrue(is_valid(source_id, descriptor))
def test_invalid(self): for s in (MISSING_ENABLED, MISSING_TYPE, MISSING_BASE_URL): fp = StringIO(s) config = Config(fp) for source_id, descriptor in config.items(): self.assertFalse(is_valid(source_id, descriptor))
def test_valid(self): fp = StringIO(VALID) config = Config(fp) for source_id, descriptor in config.items(): self.assertTrue(is_valid(source_id, descriptor))