def test_loading_metadata_from_dir_of_m4a_files(mocker): test_dir = pathlib.Path(__file__).parent.parent src = os.path.join(test_dir, "sample_data") mocker.side_effect = mock_m4a_processing ldr = loader.AudioTaggerMetadataLoader(src=src, logger=logger) out = ldr.load_metadata_df() assert "\u00a9nam" in out
def loaded_m4a_data(): """Raw m4a data before any processing. """ test_dir = pathlib.Path(__file__).parent.parent src = os.path.join(test_dir, "sample_data") ldr = loader.AudioTaggerMetadataLoader(src=src, logger=logger) # pylint: disable=protected-access df = ldr._load_all_m4a_files_into_df_from_path() return df
def input_object(): """Returns an input instance with metadata structure. """ test_dir = pathlib.Path(__file__).parent.parent src = os.path.join(test_dir, "sample_data/test_metadata.xlsx") ldr = loader.AudioTaggerMetadataLoader(src) metadata = ldr.load_metadata_df() input_obj = at_in.AudioTaggerInput() input_obj.set_metadata(metadata) return input_obj
def load_metadata(self, src): """Loads metadata from loader. Args: src (str): Path to Excel/csv/m4a or directory of m4a. Returns: void """ self.logger.info("Loading from %s", src) ldr = loader.AudioTaggerMetadataLoader(src=src, logger=self.logger) data = ldr.load_metadata_df() self.set_metadata(data)
def test_loading_metadata_from_nonexistent_audio_file(): with pytest.raises(Exception): src = "file.m4a" ldr = loader.AudioTaggerMetadataLoader(src=src, logger=logger) ldr.load_metadata_df()
def test_loading_metadata_from_nonexistent_xl_file(): with pytest.raises(ValueError): src = "file.xlsx" ldr = loader.AudioTaggerMetadataLoader(src=src, logger=logger) ldr.load_metadata_df()
def test_loading_metadata_from_invalid_src(): with pytest.raises(Exception): ldr = loader.AudioTaggerMetadataLoader(src=None, logger=logger) ldr.load_metadata_df()