Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
    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)
Esempio n. 5
0
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()
Esempio n. 6
0
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()
Esempio n. 7
0
def test_loading_metadata_from_invalid_src():
    with pytest.raises(Exception):
        ldr = loader.AudioTaggerMetadataLoader(src=None, logger=logger)
        ldr.load_metadata_df()