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()
예제 #2
0
 def setUp(self):
     self.fl_associated_files_manager = FlAssociatedFilesManager([{
         'name':
         'test1_file',
         'description':
         'test1 description of the file',
         'path':
         path + '/../res/test_text_files/test1_file',
         'task_epochs':
         '1,2'
     }, {
         'name':
         'test2_file',
         'description':
         'test2 description of the file',
         'path':
         path + '/../res/test_text_files/test2_file',
         'task_epochs':
         '1,2'
     }])
예제 #3
0
class TestFlAssociatedFilesManager(unittest.TestCase):
    def setUp(self):
        self.fl_associated_files_manager = FlAssociatedFilesManager([{
            'name':
            'test1_file',
            'description':
            'test1 description of the file',
            'path':
            path + '/../res/test_text_files/test1_file',
            'task_epochs':
            '1,2'
        }, {
            'name':
            'test2_file',
            'description':
            'test2 description of the file',
            'path':
            path + '/../res/test_text_files/test2_file',
            'task_epochs':
            '1,2'
        }])

    def test_fl_associated_files_manager_get_fl_associated_files_successfully(
            self):
        fl_associated_files = self.fl_associated_files_manager.get_fl_associated_files(
        )

        self.assertEqual(2, len(fl_associated_files))
        self.assertEqual('test1_file', fl_associated_files[0].name)
        self.assertEqual('test2 description of the file',
                         fl_associated_files[1].description)
        self.assertEqual('some test text inside from test1_file',
                         fl_associated_files[0].content)

    @should_raise(TypeError)
    def test_fl_associated_files_manager_fail_none_param_associated_files_metadata(
            self):
        fl_associated_files_manager = FlAssociatedFilesManager(None)

    def test_if_associated_files_empty(self):
        fl_associated_files_manager = FlAssociatedFilesManager([])
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)
예제 #5
0
 def test_if_associated_files_empty(self):
     fl_associated_files_manager = FlAssociatedFilesManager([])
예제 #6
0
 def test_fl_associated_files_manager_fail_none_param_associated_files_metadata(
         self):
     fl_associated_files_manager = FlAssociatedFilesManager(None)