test_data_fingerprint.py 785 Bytes
Newer Older
1
# Copyright (C) 2011 Lukas Lalinsky
2
# Distributed under the MIT license, see the LICENSE file for details.
3

4 5
from nose.tools import assert_equals
from tests import with_database
6 7 8 9 10 11
from acoustid.data.fingerprint import insert_fingerprint


@with_database
def test_insert_fingerprint(conn):
    id = insert_fingerprint(conn, {
12
        'fingerprint': [1, 2, 3, 4, 5, 6],
13 14
        'length': 123,
        'bitrate': 192,
15
        'source_id': 1,
16 17 18
        'format_id': 1,
        'track_id': 2,
    })
19
    assert_equals(1, id)
20
    rows = conn.execute("""
21
        SELECT fingerprint, length, bitrate, format_id, track_id
22 23 24
        FROM fingerprint WHERE id=%s
    """, (id,)).fetchall()
    expected_rows = [
25
        ([1, 2, 3, 4, 5, 6], 123, 192, 1, 2),
26 27
    ]
    assert_equals(expected_rows, rows)