diff --git a/ingen/data_source/file_source.py b/ingen/data_source/file_source.py index f25841e..0f2f77a 100644 --- a/ingen/data_source/file_source.py +++ b/ingen/data_source/file_source.py @@ -6,6 +6,7 @@ from ingen.data_source.source import DataSource from ingen.reader.file_reader import ReaderFactory +from ingen.utils.interpolators.Interpolator import Interpolator from ingen.utils.path_parser import PathParser from ingen.utils.timer import log_time @@ -17,7 +18,7 @@ class FileSource(DataSource): This class represents a File source """ - def __init__(self, source, params_map): + def __init__(self, source, params_map, interpolator=Interpolator()): """ Loads a file @@ -26,6 +27,7 @@ def __init__(self, source, params_map): """ super().__init__(source.get('id')) + self.interpolator = interpolator if params_map.get('infile') and source['use_infile']: source['file_path'] = params_map['infile'] self._src = source @@ -61,7 +63,7 @@ def format_file_path(self, source, params_map): else: run_date = params_map.get('run_date', date.today()) - path_parser = PathParser(run_date) + path_parser = PathParser(run_date, interpolator=self.interpolator) if 'file_path' in source: source['file_path'] = path_parser.parse(source['file_path']) return source diff --git a/test/data_source/test_file_source.py b/test/data_source/test_file_source.py index c5aaa24..04a0e8a 100644 --- a/test/data_source/test_file_source.py +++ b/test/data_source/test_file_source.py @@ -26,7 +26,7 @@ def setUp(self): self.params_map = {'query_params': {'table_name': 'positions'}, 'infile': {}} self.source = FileSource(self._src, self.params_map) - @patch('src.data_source.file_source.ReaderFactory') + @patch('ingen.data_source.file_source.ReaderFactory') def test_source_fetch(self, mock_reader_factory): fileReader = Mock() fileReader.read.return_value = pd.DataFrame()