Commit 89a9a60d authored by Lukáš Lalinský's avatar Lukáš Lalinský

Fix tests

parent 2592125c
......@@ -114,7 +114,7 @@ CREATE TABLE foreignid_vendor (
CREATE TABLE foreignid (
id serial NOT NULL,
vendor_id int NOT NULL,
name text(256) NOT NULL
name text NOT NULL
);
CREATE TABLE track_foreignid (
......
......@@ -113,7 +113,7 @@ INSERT INTO track (id, gid) VALUES
(2, '92732e4b-97c6-4250-b237-1636384d466f'),
(3, '30e66c45-f761-490a-b1bd-55763e8b59be'),
(4, '014e973b-368e-42bf-b619-84cab14c4af6');
INSERT INTO track_mbid (track_id, mbid) VALUES (1, 'b81f83ee-4da4-11e0-9ed8-0025225356f3');
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, 'b81f83ee-4da4-11e0-9ed8-0025225356f3', 1);
INSERT INTO musicbrainz.artist_name (id, name) VALUES
(1, 'Artist A');
......
......@@ -93,8 +93,8 @@ def test_lookup_handler(conn):
assert_equals('200 OK', resp.status)
# one exact match
prepare_database(conn, """
INSERT INTO fingerprint (length, fingerprint, track_id)
VALUES (%s, %s, 1);
INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
VALUES (%s, %s, 1, 1);
""", (TEST_1_LENGTH, TEST_1_FP_RAW))
handler = LookupHandler(connect=provider(conn))
resp = handler.handle(Request(builder.get_environ()))
......
......@@ -51,15 +51,15 @@ def test_error():
@with_database
def test_api_handler_params_jsonp(conn):
values = MultiDict({'client': 'app1key', 'format': 'jsonp'})
params = LookupHandlerParams()
params = APIHandlerParams()
params.parse(values, conn)
assert_equals('jsonp:jsonAcoustidApi', params.format)
values = MultiDict({'client': 'app1key', 'format': 'jsonp', 'jsoncallback': '$foo'})
params = LookupHandlerParams()
params = APIHandlerParams()
params.parse(values, conn)
assert_equals('jsonp:$foo', params.format)
values = MultiDict({'client': 'app1key', 'format': 'jsonp', 'jsoncallback': '///'})
params = LookupHandlerParams()
params = APIHandlerParams()
params.parse(values, conn)
assert_equals('jsonp:jsonAcoustidApi', params.format)
......@@ -163,8 +163,8 @@ def test_lookup_handler(conn):
assert_equals('200 OK', resp.status)
# one exact match
prepare_database(conn, """
INSERT INTO fingerprint (length, fingerprint, track_id)
VALUES (%s, %s, 1);
INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
VALUES (%s, %s, 1, 1);
""", (TEST_1_LENGTH, TEST_1_FP_RAW))
handler = LookupHandler(connect=provider(conn))
resp = handler.handle(Request(builder.get_environ()))
......@@ -195,7 +195,7 @@ INSERT INTO fingerprint (length, fingerprint, track_id)
assert_json_equals(expected, resp.data)
assert_equals('200 OK', resp.status)
# one exact match with MBIDs and metadata
prepare_database(conn, "INSERT INTO track_mbid (track_id, mbid) VALUES (1, '373e6728-35e3-4633-aab1-bf7092ec43d8')")
prepare_database(conn, "INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, '373e6728-35e3-4633-aab1-bf7092ec43d8', 1)")
values = {'format': 'json', 'client': 'app1key', 'duration': str(TEST_1_LENGTH), 'fingerprint': TEST_1_FP, 'meta': '2'}
builder = EnvironBuilder(method='POST', data=values)
handler = LookupHandler(connect=provider(conn))
......@@ -253,8 +253,8 @@ INSERT INTO fingerprint (length, fingerprint, track_id)
assert_equals('200 OK', resp.status)
# duplicate fingerprint
prepare_database(conn, """
INSERT INTO fingerprint (length, fingerprint, track_id)
VALUES (%s, %s, 1);
INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
VALUES (%s, %s, 1, 1);
""", (TEST_1_LENGTH, TEST_1_FP_RAW))
values = {'format': 'json', 'client': 'app1key', 'duration': str(TEST_1_LENGTH), 'fingerprint': TEST_1_FP}
builder = EnvironBuilder(method='POST', data=values)
......
......@@ -144,8 +144,8 @@ def test_import_submission(conn):
@with_database
def test_import_submission_reuse_fingerprint_97(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp)s, %(len)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp)s, %(len)s, 1, 1);
""", dict(fp=TEST_1A_FP_RAW, len=TEST_1A_LENGTH))
id = insert_submission(conn, {
'fingerprint': TEST_1B_FP_RAW,
......@@ -165,8 +165,8 @@ def test_import_submission_reuse_fingerprint_97(conn):
@with_database
def test_import_submission_reuse_fingerprint_100(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp)s, %(len)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp)s, %(len)s, 1, 1);
""", dict(fp=TEST_1A_FP_RAW, len=TEST_1A_LENGTH))
id = insert_submission(conn, {
'fingerprint': TEST_1A_FP_RAW,
......@@ -186,8 +186,8 @@ def test_import_submission_reuse_fingerprint_100(conn):
@with_database
def test_import_submission_reuse_track_93(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp)s, %(len)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp)s, %(len)s, 1, 1);
""", dict(fp=TEST_1A_FP_RAW, len=TEST_1A_LENGTH))
id = insert_submission(conn, {
'fingerprint': TEST_1C_FP_RAW,
......@@ -207,8 +207,8 @@ def test_import_submission_reuse_track_93(conn):
@with_database
def test_import_submission_new_track(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp)s, %(len)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp)s, %(len)s, 1, 1);
""", dict(fp=TEST_1A_FP_RAW, len=TEST_1A_LENGTH))
id = insert_submission(conn, {
'fingerprint': TEST_1D_FP_RAW,
......@@ -233,8 +233,8 @@ def test_import_submission_new_track(conn):
@with_database
def test_import_submission_new_track_different(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp)s, %(len)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp)s, %(len)s, 1, 1);
""", dict(fp=TEST_1A_FP_RAW, len=TEST_1A_LENGTH))
id = insert_submission(conn, {
'fingerprint': TEST_2_FP_RAW,
......@@ -254,8 +254,8 @@ def test_import_submission_new_track_different(conn):
@with_database
def test_import_submission_merge_existing_tracks(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp1)s, %(len1)s, 1), (%(fp2)s, %(len2)s, 2);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp1)s, %(len1)s, 1, 1), (%(fp2)s, %(len2)s, 2, 1);
""", dict(fp1=TEST_1A_FP_RAW, len1=TEST_1A_LENGTH,
fp2=TEST_1B_FP_RAW, len2=TEST_1B_LENGTH))
id = insert_submission(conn, {
......
......@@ -45,12 +45,12 @@ INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, 'd575d506-4
def test_merge_missing_mbids(conn):
prepare_database(conn, """
TRUNCATE track_mbid CASCADE;
INSERT INTO track_mbid (track_id, mbid) VALUES (1, '97edb73c-4dac-11e0-9096-0025225356f3');
INSERT INTO track_mbid (track_id, mbid) VALUES (1, 'b81f83ee-4da4-11e0-9ed8-0025225356f3');
INSERT INTO track_mbid (track_id, mbid) VALUES (1, 'd575d506-4da4-11e0-b951-0025225356f3');
INSERT INTO track_mbid (track_id, mbid) VALUES (2, 'd575d506-4da4-11e0-b951-0025225356f3');
INSERT INTO track_mbid (track_id, mbid) VALUES (3, '97edb73c-4dac-11e0-9096-0025225356f3');
INSERT INTO track_mbid (track_id, mbid) VALUES (4, '5d0290a6-4dad-11e0-a47a-0025225356f3');
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, '97edb73c-4dac-11e0-9096-0025225356f3', 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, 'b81f83ee-4da4-11e0-9ed8-0025225356f3', 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, 'd575d506-4da4-11e0-b951-0025225356f3', 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (2, 'd575d506-4da4-11e0-b951-0025225356f3', 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (3, '97edb73c-4dac-11e0-9096-0025225356f3', 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (4, '5d0290a6-4dad-11e0-a47a-0025225356f3', 1);
INSERT INTO musicbrainz.recording_gid_redirect (new_id, gid) VALUES
(1, 'd575d506-4da4-11e0-b951-0025225356f3'),
(2, '5d0290a6-4dad-11e0-a47a-0025225356f3'),
......@@ -79,8 +79,8 @@ def test_insert_track(conn):
@with_database
def test_merge_tracks(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp1)s, %(len1)s, 1), (%(fp2)s, %(len2)s, 2);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp1)s, %(len1)s, 1, 1), (%(fp2)s, %(len2)s, 2, 1);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, '97edb73c-4dac-11e0-9096-0025225356f3', 10);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (1, 'd575d506-4da4-11e0-b951-0025225356f3', 15);
INSERT INTO track_mbid (track_id, mbid, submission_count) VALUES (2, 'd575d506-4da4-11e0-b951-0025225356f3', 50);
......@@ -119,9 +119,9 @@ INSERT INTO track_puid (track_id, puid, submission_count) VALUES (4, '5d0290a6-4
@with_database
def test_track_fingerprint_matrix(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp1)s, %(len1)s, 1), (%(fp2)s, %(len2)s, 1),
(%(fp3)s, %(len3)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp1)s, %(len1)s, 1, 1), (%(fp2)s, %(len2)s, 1, 1),
(%(fp3)s, %(len3)s, 1, 1);
""", dict(fp1=TEST_1A_FP_RAW, len1=TEST_1A_LENGTH,
fp2=TEST_1B_FP_RAW, len2=TEST_1B_LENGTH,
fp3=TEST_1C_FP_RAW, len3=TEST_1C_LENGTH))
......@@ -138,9 +138,9 @@ INSERT INTO fingerprint (fingerprint, length, track_id)
@with_database
def test_can_merge_tracks(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp1)s, %(len1)s, 1), (%(fp2)s, %(len2)s, 2),
(%(fp3)s, %(len3)s, 3);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp1)s, %(len1)s, 1, 1), (%(fp2)s, %(len2)s, 2, 1),
(%(fp3)s, %(len3)s, 3, 1);
""", dict(fp1=TEST_1A_FP_RAW, len1=TEST_1A_LENGTH,
fp2=TEST_1B_FP_RAW, len2=TEST_1B_LENGTH,
fp3=TEST_2_FP_RAW, len3=TEST_2_LENGTH))
......@@ -151,8 +151,8 @@ INSERT INTO fingerprint (fingerprint, length, track_id)
@with_database
def test_can_add_fp_to_track(conn):
prepare_database(conn, """
INSERT INTO fingerprint (fingerprint, length, track_id)
VALUES (%(fp1)s, %(len1)s, 1);
INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
VALUES (%(fp1)s, %(len1)s, 1, 1);
""", dict(fp1=TEST_1A_FP_RAW, len1=TEST_1A_LENGTH))
res = can_add_fp_to_track(conn, 1, TEST_2_FP_RAW)
assert_equal(False, res)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment