def setUp(self): self.fl_associated_files = [ FlAssociatedFile('test_name1', 'test description 1', 'test content 1', '1,2'), FlAssociatedFile('test_name2', 'test description 2', 'test content 2', '1,2') ] self.associated_files_creator = AssociatedFilesCreator()
def __init__(self, metadata): if 'associated_files' in metadata: validation_registrator = ValidationRegistrator() validation_registrator.register( AssociatedFilesValidator(metadata['associated_files'])) validation_registrator.validate() self.fl_associated_files_manager = FlAssociatedFilesManager( metadata['associated_files']) self.associated_files_creator = AssociatedFilesCreator() self.associated_files_injector = AssociatedFilesInjector()
class TestFlAssociatedFilesCreator(unittest.TestCase): def setUp(self): self.fl_associated_files = [ FlAssociatedFile('test_name1', 'test description 1', 'test content 1', '1,2'), FlAssociatedFile('test_name2', 'test description 2', 'test content 2', '1,2') ] self.associated_files_creator = AssociatedFilesCreator() def test_fl_associated_files_creator_create_successfully(self): associated_files = [ self.associated_files_creator.create(fl_associated_file) for fl_associated_file in self.fl_associated_files ] self.assertEqual(2, len(associated_files)) self.assertIsInstance(associated_files[0], AssociatedFiles) self.assertEqual('test_name1', associated_files[0].name) self.assertEqual('test description 2', associated_files[1].fields['description']) self.assertEqual('test content 2', associated_files[1].fields['content'])
class AssociatedFilesOriginator: def __init__(self, metadata): if 'associated_files' in metadata: validation_registrator = ValidationRegistrator() validation_registrator.register( AssociatedFilesValidator(metadata['associated_files'])) validation_registrator.validate() self.fl_associated_files_manager = FlAssociatedFilesManager( metadata['associated_files']) self.associated_files_creator = AssociatedFilesCreator() self.associated_files_injector = AssociatedFilesInjector() def make(self, nwb_content): logger.info('AssociatedFiles: Building') fl_associated_files = self.fl_associated_files_manager.get_fl_associated_files( ) logger.info('AssociatedFiles: Creating') associated_files = [ self.associated_files_creator.create(fl_associated_file) for fl_associated_file in fl_associated_files ] logger.info('AssociatedFiles: Injecting') self.associated_files_injector.inject(associated_files, 'associated_files', nwb_content)