Esempio n. 1
0
 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))
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
 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))
Esempio n. 5
0
 def test_valid(self):
     fp = StringIO(VALID)
     config = Config(fp)
     for source_id, descriptor in config.items():
         self.assertTrue(is_valid(source_id, descriptor))
Esempio n. 6
0
 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))
Esempio n. 7
0
 def test_valid(self):
     fp = StringIO(VALID)
     config = Config(fp)
     for source_id, descriptor in config.items():
         self.assertTrue(is_valid(source_id, descriptor))