コード例 #1
0
def test_basic():
    filename = os.path.basename(DEFAULT_AUDIO_FILE)
    q = Queue.Queue()
    file_prefix = u''
    storage_backend = "file"
    #This actually imports the file into the "./Test Artist" directory.
    AnalyzerPipeline.run_analysis(q, DEFAULT_AUDIO_FILE, u'.', filename, storage_backend, file_prefix)
    metadata = q.get()
    assert metadata['track_title'] == u'Test Title'
    assert metadata['artist_name'] == u'Test Artist'
    assert metadata['album_title'] == u'Test Album'
    assert metadata['year'] == u'1999'
    assert metadata['genre'] == u'Test Genre'
    assert metadata['mime'] == 'audio/mp3' # Not unicode because MIMEs aren't.
    assert abs(metadata['length_seconds'] - 3.9) < 0.1
    assert metadata["length"] == str(datetime.timedelta(seconds=metadata["length_seconds"]))
    assert os.path.exists(DEFAULT_IMPORT_DEST)
コード例 #2
0
def test_run_analysis(src_dir, dest_dir):
    queue = Queue()
    AnalyzerPipeline.run_analysis(
        queue,
        os.path.join(src_dir, AUDIO_FILENAME),
        dest_dir,
        AUDIO_FILENAME,
        "file",
        "",
    )
    metadata = queue.get()

    assert metadata["track_title"] == "Test Title"
    assert metadata["artist_name"] == "Test Artist"
    assert metadata["album_title"] == "Test Album"
    assert metadata["year"] == "1999"
    assert metadata["genre"] == "Test Genre"
    assert metadata["mime"] == "audio/mp3"
    assert abs(metadata["length_seconds"] - 3.9) < 0.1
    assert metadata["length"] == str(
        datetime.timedelta(seconds=metadata["length_seconds"])
    )
    assert os.path.exists(os.path.join(dest_dir, AUDIO_IMPORT_DEST))
コード例 #3
0
def test_run_analysis_wrong_params(params, exception):
    with pytest.raises(exception):
        AnalyzerPipeline.run_analysis(*params)
コード例 #4
0
def test_wrong_type_string_param4():
    AnalyzerPipeline.run_analysis(Queue.Queue(), u'', u'', '')
コード例 #5
0
def test_wrong_type_queue_param():
    AnalyzerPipeline.run_analysis(Queue.Queue(), u'', u'', u'')