Commit 3fa39d09 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Flake8 fixes in tests

parent 1feb2f1d
Pipeline #20313 passed with stage
in 1 minute and 1 second
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
......@@ -71,4 +71,3 @@ class SubmitHandlerParams(v2.SubmitHandlerParams):
class SubmitHandler(v2.SubmitHandler):
params_class = SubmitHandlerParams
......@@ -748,4 +748,3 @@ class SubmitHandler(APIHandler):
self.redis.decr(clients_waiting_key)
return response
......@@ -37,7 +37,7 @@ class TrackListByMBIDHandler(APIHandler):
response = {}
condition = schema.track_mbid.c.mbid.in_(params.mbids)
if not params.disabled:
condition = sql.and_(condition, schema.track_mbid.c.disabled == False)
condition = sql.and_(condition, schema.track_mbid.c.disabled == False) # noqa: F712
query = sql.select([schema.track_mbid.c.mbid, schema.track_mbid.c.disabled, schema.track.c.gid],
condition, schema.track_mbid.join(schema.track))
tracks_map = {}
......@@ -185,4 +185,3 @@ class GetFingerprintHandler(APIHandler):
'hashes': fingerprint.fingerprint,
'duration': fingerprint.length,
}}
......@@ -21,4 +21,3 @@ FINGERPRINT_MAX_LENGTH_DIFF = 7
FINGERPRINT_MAX_ALLOWED_LENGTH_DIFF = 30
MAX_REQUESTS_PER_SECOND = 3
......@@ -79,4 +79,3 @@ def reset_account_apikey(conn, id):
def is_moderator(conn, id):
query = sql.select([schema.account.c.mbuser], schema.account.c.id == id)
return bool(conn.execute(query).scalar())
......@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
def lookup_application_id_by_apikey(conn, apikey, only_active=False):
query = sql.select([schema.application.c.id], schema.application.c.apikey == apikey)
if only_active:
query = query.where(schema.application.c.active == True)
query = query.where(schema.application.c.active == True) # noqa: F712
return conn.execute(query).scalar()
......
......@@ -185,4 +185,3 @@ def update_fingerprint_index(db, index, limit=1000):
if in_transaction:
index.commit()
logger.info("Updated index %s up to fingerprint %s", index, last_id)
......@@ -32,4 +32,3 @@ def find_or_insert_foreignid(conn, full_name):
id = conn.execute(insert_stmt).inserted_primary_key[0]
logger.info("Inserted foreign ID %d with name %s", id, full_name)
return id
......@@ -229,7 +229,7 @@ def find_all_contributors(conn):
schema.account.c.submission_count,
])
query = query.where(schema.account.c.submission_count > 0)
query = query.where(schema.account.c.anonymous == False)
query = query.where(schema.account.c.anonymous == False) # noqa: F712
query = query.order_by(schema.account.c.submission_count.desc(),
schema.account.c.name,
schema.account.c.id)
......
......@@ -109,8 +109,10 @@ def import_queued_submissions(conn, index=None, limit=100, ids=None):
"""
Import the given submission into the main fingerprint database
"""
query = schema.submission.select(schema.submission.c.handled == False).\
order_by(schema.submission.c.mbid.nullslast(), schema.submission.c.id.desc())
query = (
schema.submission.select(schema.submission.c.handled == False) # noqa: F712
.order_by(schema.submission.c.mbid.nullslast(), schema.submission.c.id.desc())
)
if ids is not None:
query = query.where(schema.submission.c.id.in_(ids))
if limit is not None:
......
......@@ -35,7 +35,7 @@ def lookup_mbids(conn, track_ids):
schema.track_mbid.c.mbid,
schema.track_mbid.c.submission_count,
])
query = query.where(sql.and_(schema.track_mbid.c.track_id.in_(track_ids), schema.track_mbid.c.disabled == False))
query = query.where(sql.and_(schema.track_mbid.c.track_id.in_(track_ids), schema.track_mbid.c.disabled == False)) # noqa: F712
query = query.order_by(schema.track_mbid.c.mbid)
results = {}
for track_id, mbid, sources in conn.execute(query):
......@@ -60,7 +60,7 @@ def lookup_tracks(conn, mbids):
return {}
query = sql.select(
[schema.track_mbid.c.track_id, schema.track.c.gid, schema.track_mbid.c.mbid],
sql.and_(schema.track_mbid.c.mbid.in_(mbids), schema.track_mbid.c.disabled == False),
sql.and_(schema.track_mbid.c.mbid.in_(mbids), schema.track_mbid.c.disabled == False), # noqa: F712
from_obj=schema.track_mbid.join(schema.track, schema.track_mbid.c.track_id == schema.track.c.id)). \
order_by(schema.track_mbid.c.track_id)
results = {}
......
......@@ -208,4 +208,3 @@ class IndexClientPool(object):
client = IndexClient(**self.args)
# logger.debug("Checking out connection %s", client)
return IndexClientWrapper(self, client)
......@@ -88,4 +88,3 @@ def run_script(func, option_cb=None, master_only=False):
logger.debug("Script finished %s successfuly", sys.argv[0])
script.engine.dispose()
script.index.dispose()
......@@ -118,7 +118,7 @@ submission = Table('submission', metadata,
Column('foreignid_id', Integer, ForeignKey('foreignid.id')),
)
Index('submission_idx_handled', submission.c.id, postgresql_where=submission.c.handled == False)
Index('submission_idx_handled', submission.c.id, postgresql_where=submission.c.handled == False) # noqa: E712
stats = Table('stats', metadata,
Column('id', Integer, primary_key=True),
......
This diff is collapsed.
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database, assert_json_equals
from nose.tools import assert_equals
from acoustid.api import serialize_response
......@@ -26,7 +25,10 @@ def test_serialize_xml():
data = {'status': 'ok', 'artists': [{'name': 'Jean Michel Jarre', 'year': 1948, 'cities': ['Paris', 'Lyon']}]}
resp = serialize_response(data, 'xml')
assert_equals('text/xml; charset=UTF-8', resp.content_type)
expected = '''<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><artists><artist><cities><city>Paris</city><city>Lyon</city></cities><name>Jean Michel Jarre</name><year>1948</year></artist></artists></response>'''
expected = (
'''<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><artists><artist><cities><city>Paris</city><city>Lyon'''
'''</city></cities><name>Jean Michel Jarre</name><year>1948</year></artist></artists></response>'''
)
assert_equals(expected, resp.data)
......@@ -36,4 +38,3 @@ def test_serialize_xml_attribute():
assert_equals('text/xml; charset=UTF-8', resp.content_type)
expected = '''<?xml version='1.0' encoding='UTF-8'?>\n<response status="ok" />'''
assert_equals(expected, resp.data)
......@@ -2,9 +2,10 @@
# Distributed under the MIT license, see the LICENSE file for details.
import unittest
from nose.tools import *
from nose.tools import assert_equals, assert_raises
import tests
from tests import (prepare_database, with_database, assert_json_equals,
from tests import (
prepare_database, with_database,
TEST_1_LENGTH,
TEST_1_FP,
TEST_1_FP_RAW,
......@@ -119,7 +120,6 @@ INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
resp = handler.handle(Request(builder.get_environ()))
assert_equals('text/xml; charset=UTF-8', resp.content_type)
expected = "<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><results><result><tracks><track><id>b81f83ee-4da4-11e0-9ed8-0025225356f3</id></track></tracks><score>1.0</score><id>eb31d1c3-950e-468b-9e36-e46fa75b1291</id></result></results></response>"
#expected = "<?xml version='1.0' encoding='UTF-8'?>\n<response><status>ok</status><results><result><tracks><track><length>123</length><artist><id>a64796c0-4da4-11e0-bf81-0025225356f3</id><name>Artist A</name></artist><id>b81f83ee-4da4-11e0-9ed8-0025225356f3</id><releases><release><track_num>1</track_num><id>dd6c2cca-a0e9-4cc4-9a5f-7170bd098e23</id><track_count>2</track_count><name>Album A</name></release></releases><name>Track A</name></track></tracks><score>1.0</score><id>1</id></result></results></response>"
assert_equals(expected, resp.data)
assert_equals('200 OK', resp.status)
......@@ -175,7 +175,8 @@ def test_submit_handler_params(conn):
assert_equals(192, params.submissions[0]['bitrate'])
assert_equals('MP3', params.submissions[0]['format'])
# all ok (single submission)
values = MultiDict({'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'client': 'app1key', 'user': 'user1key',
'mbid.0': '4d814cb1-20ec-494f-996f-f31ca8a49784',
'puid.0': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'length.0': str(TEST_1_LENGTH),
......
......@@ -3,9 +3,10 @@
import json
import unittest
from nose.tools import *
from nose.tools import assert_equals, assert_raises, assert_true
import tests
from tests import (prepare_database, with_database, assert_json_equals,
from tests import (
prepare_database, with_database, assert_json_equals,
TEST_1_LENGTH,
TEST_1_FP,
TEST_1_FP_RAW,
......@@ -32,6 +33,7 @@ from acoustid.api.v2.misc import (
)
from acoustid.utils import provider
def test_ok():
handler = APIHandler()
resp = handler._ok({'tracks': [{'id': 1, 'name': 'Track 1'}]}, 'json')
......@@ -233,8 +235,8 @@ INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
},
},
"artists": [{
"id": "a64796c0-4da4-11e0-bf81-0025225356f3",
"name": "Artist A",
"id": "a64796c0-4da4-11e0-bf81-0025225356f3",
"name": "Artist A",
}],
}, {
"title": "Track A",
......@@ -250,8 +252,8 @@ INSERT INTO fingerprint (length, fingerprint, track_id, submission_count)
},
},
"artists": [{
"id": "a64796c0-4da4-11e0-bf81-0025225356f3",
"name": "Artist A",
"id": "a64796c0-4da4-11e0-bf81-0025225356f3",
"name": "Artist A",
}],
}],
}],
......@@ -307,7 +309,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.MissingParameterError, params.parse, values, conn)
# wrong foreign id
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'foreignid': 'aaa',
'duration': str(TEST_1_LENGTH),
'fingerprint': TEST_1_FP,
......@@ -317,7 +320,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.InvalidForeignIDError, params.parse, values, conn)
# wrong mbid
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid': '4d814cb1-20ec-494f-996f-xxxxxxxxxxxx',
'duration': str(TEST_1_LENGTH),
'fingerprint': TEST_1_FP,
......@@ -327,7 +331,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.InvalidUUIDError, params.parse, values, conn)
# one wrong mbid, one good
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid': ['4d814cb1-20ec-494f-996f-xxxxxxxxxxxx', '66c0f5cc-67b6-4f51-80cd-ab26b5aaa6ea'],
'duration': str(TEST_1_LENGTH),
'fingerprint': TEST_1_FP,
......@@ -337,7 +342,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.InvalidUUIDError, params.parse, values, conn)
# wrong puid
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'puid': '4d814cb1-20ec-494f-996f-xxxxxxxxxxxx',
'duration': str(TEST_1_LENGTH),
'fingerprint': TEST_1_FP,
......@@ -347,7 +353,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.InvalidUUIDError, params.parse, values, conn)
# empty fingerprint
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid': ['4d814cb1-20ec-494f-996f-f31ca8a49784', '66c0f5cc-67b6-4f51-80cd-ab26b5aaa6ea'],
'puid': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'duration': str(TEST_1_LENGTH),
......@@ -358,7 +365,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.MissingParameterError, params.parse, values, conn)
# missing duration
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid': ['4d814cb1-20ec-494f-996f-f31ca8a49784', '66c0f5cc-67b6-4f51-80cd-ab26b5aaa6ea'],
'puid': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'fingerprint': TEST_1_FP,
......@@ -368,7 +376,8 @@ def test_submit_handler_params(conn):
params = SubmitHandlerParams(tests.script.config)
assert_raises(errors.MissingParameterError, params.parse, values, conn)
# all ok (single submission)
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid': ['4d814cb1-20ec-494f-996f-f31ca8a49784', '66c0f5cc-67b6-4f51-80cd-ab26b5aaa6ea'],
'puid': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'foreignid': 'foo:123',
......@@ -388,7 +397,8 @@ def test_submit_handler_params(conn):
assert_equals(192, params.submissions[0]['bitrate'])
assert_equals('MP3', params.submissions[0]['format'])
# all ok (multiple submissions)
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid.0': '4d814cb1-20ec-494f-996f-f31ca8a49784',
'puid.0': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'duration.0': str(TEST_1_LENGTH),
......@@ -418,7 +428,8 @@ def test_submit_handler_params(conn):
assert_equals(500, params.submissions[1]['bitrate'])
assert_equals('FLAC', params.submissions[1]['format'])
# one incorrect, one correct
values = MultiDict({'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = MultiDict({
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'mbid.0': '4d814cb1-20ec-494f-996f-f31ca8a49784',
'puid.0': '4e823498-c77d-4bfb-b6cc-85b05c2783cf',
'duration.0': str(TEST_1_LENGTH),
......@@ -466,7 +477,8 @@ def test_submit_handler(conn):
@with_database
def test_submit_handler_with_meta(conn):
values = {'format': 'json', 'client': 'app1key', 'user': 'user1key',
values = {
'format': 'json', 'client': 'app1key', 'user': 'user1key',
'duration': str(TEST_1_LENGTH), 'fingerprint': TEST_1_FP, 'bitrate': 192,
'mbid': 'b9c05616-1874-4d5d-b30e-6b959c922d28', 'fileformat': 'FLAC',
'track': 'Voodoo People',
......@@ -580,8 +592,8 @@ def test_user_lookup_handler(conn):
assert_equals('application/json; charset=UTF-8', resp.content_type)
assert_equals('200 OK', resp.status)
data = json.loads(resp.data)
assert_equal('ok', data['status'])
assert_equal('user1key', data['user']['apikey'])
assert_equals('ok', data['status'])
assert_equals('user1key', data['user']['apikey'])
@with_database
......@@ -593,6 +605,5 @@ def test_user_lookup_handler_missing(conn):
assert_equals('application/json; charset=UTF-8', resp.content_type)
assert_equals('400 BAD REQUEST', resp.status)
data = json.loads(resp.data)
assert_equal('error', data['status'])
assert_equal(6, data['error']['code'])
assert_equals('error', data['status'])
assert_equals(6, data['error']['code'])
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals, assert_not_equal, assert_true
from tests import with_database
from acoustid.data.account import (
lookup_account_id_by_apikey,
get_account_details,
......@@ -22,7 +22,7 @@ def test_lookup_account_id_by_apikey(conn):
@with_database
def test_reset_account_apikey(conn):
info = get_account_details(conn, 1)
assert_equal('user1key', info['apikey'])
assert_equals('user1key', info['apikey'])
reset_account_apikey(conn, 1)
info = get_account_details(conn, 1)
assert_not_equal('user1key', info['apikey'])
......@@ -34,4 +34,3 @@ def test_update_account_lastlogin(conn):
update_account_lastlogin(conn, 1)
info2 = get_account_details(conn, 1)
assert_true(info1['lastlogin'] < info2['lastlogin'])
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals
from tests import with_database
from acoustid.data.application import lookup_application_id_by_apikey
......@@ -12,4 +12,3 @@ def test_lookup_application_id_by_apikey(conn):
assert_equals(1, id)
id = lookup_application_id_by_apikey(conn, 'foooo')
assert_equals(None, id)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals
from tests import with_database
from acoustid.data.fingerprint import insert_fingerprint
@with_database
def test_insert_fingerprint(conn):
id = insert_fingerprint(conn, {
'fingerprint': [1,2,3,4,5,6],
'fingerprint': [1, 2, 3, 4, 5, 6],
'length': 123,
'bitrate': 192,
'source_id': 1,
......@@ -22,7 +22,6 @@ def test_insert_fingerprint(conn):
FROM fingerprint WHERE id=%s
""", (id,)).fetchall()
expected_rows = [
([1,2,3,4,5,6], 123, 192, 1, 2),
([1, 2, 3, 4, 5, 6], 123, 192, 1, 2),
]
assert_equals(expected_rows, rows)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals
from tests import with_database
from acoustid.data.format import find_or_insert_format
......@@ -18,4 +18,3 @@ def test_find_or_insert_format(conn):
(2, 'MP3'),
]
assert_equals(expected_rows, rows)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals
from tests import with_database
from acoustid.data.meta import insert_meta
......@@ -30,4 +30,3 @@ def test_insert_meta(conn):
'year': 2030
}
assert_equals(expected, dict(row))
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from tests import prepare_database, with_database
from nose.tools import assert_equals
from tests import with_database
from acoustid.data.source import find_or_insert_source
......@@ -27,4 +27,3 @@ def test_find_or_insert_source(conn):
(3, 2, 1),
]
assert_equals(expected_rows, rows)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from nose.tools import assert_equals
from tests import prepare_database, with_database
from acoustid.data.stats import (
find_current_stats,
......@@ -22,4 +22,3 @@ def test_find_current_stats(conn):
stats = find_current_stats(conn)
assert_equals(4, stats['account.all'])
assert_equals(14, stats['track.all'])
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from nose.tools import assert_equals, assert_false, assert_true
from tests import (
prepare_database, with_database,
TEST_1_FP_RAW,
......@@ -25,7 +25,7 @@ from acoustid.data.submission import insert_submission, import_submission, impor
@with_database
def test_insert_submission(conn):
id = insert_submission(conn, {
'fingerprint': [1,2,3,4,5,6],
'fingerprint': [1, 2, 3, 4, 5, 6],
'length': 123,
'bitrate': 192,
'source_id': 1,
......@@ -37,7 +37,7 @@ def test_insert_submission(conn):
FROM submission WHERE id=%s
""", (id,)).fetchall()
expected_rows = [
([1,2,3,4,5,6], 123, 192, 1),
([1, 2, 3, 4, 5, 6], 123, 192, 1),
]
assert_equals(expected_rows, rows)
......@@ -322,4 +322,3 @@ def test_import_queued_submissions(conn):
assert_equals(2, count)
count = conn.execute("SELECT count(*) FROM track WHERE id IN (5,6,7)").scalar()
assert_equals(2, count)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
import unittest
from nose.tools import *
from nose.tools import assert_equals
from uuid import UUID
from tests import (
prepare_database, with_database,
TEST_1_FP_RAW,
TEST_1_LENGTH,
TEST_1A_FP_RAW,
TEST_1A_LENGTH,
TEST_1B_FP_RAW,
TEST_1B_LENGTH,
TEST_1C_FP_RAW,
TEST_1C_LENGTH,
TEST_1D_FP_RAW,
TEST_1D_LENGTH,
TEST_2_FP_RAW,
TEST_2_LENGTH,
)
from acoustid.data.track import (
merge_missing_mbids, insert_track, merge_tracks,
merge_mbids,
calculate_fingerprint_similarity_matrix,
can_merge_tracks,
can_add_fp_to_track,
)
......@@ -247,7 +239,7 @@ INSERT INTO fingerprint (fingerprint, length, track_id, submission_count)
fp2=TEST_1B_FP_RAW, len2=TEST_1B_LENGTH,
fp3=TEST_2_FP_RAW, len3=TEST_2_LENGTH))
groups = can_merge_tracks(conn, [1, 2, 3])
assert_equal([set([1, 2])], groups)
assert_equals([set([1, 2])], groups)
@with_database
......@@ -257,9 +249,8 @@ 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, TEST_2_LENGTH)
assert_equal(False, res)
assert_equals(False, res)
res = can_add_fp_to_track(conn, 1, TEST_1B_FP_RAW, TEST_1B_LENGTH + 20)
assert_equal(False, res)
assert_equals(False, res)
res = can_add_fp_to_track(conn, 1, TEST_1B_FP_RAW, TEST_1B_LENGTH)
assert_equal(True, res)
assert_equals(True, res)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from nose.tools import assert_true
from sqlalchemy import sql
from tests import prepare_database, with_database, TEST_1A_FP_RAW, TEST_1B_FP_RAW, TEST_1C_FP_RAW, TEST_1D_FP_RAW, TEST_2_FP_RAW
from tests import with_database, TEST_1A_FP_RAW, TEST_1B_FP_RAW, TEST_1C_FP_RAW, TEST_1D_FP_RAW, TEST_2_FP_RAW
from acoustid import const
from acoustid.data.fingerprint import insert_fingerprint
@with_database
......@@ -51,6 +50,3 @@ def test_match_different(conn):
query = sql.select([sql.func.acoustid_compare2(TEST_1A_FP_RAW, TEST_2_FP_RAW, 80)])
score = conn.execute(query).scalar()
assert_true(score < const.TRACK_MERGE_THRESHOLD)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from nose.tools import assert_equals
import gzip
from cStringIO import StringIO
from acoustid.server import GzipRequestMiddleware
......@@ -9,7 +9,7 @@ from acoustid.server import GzipRequestMiddleware
def test_gzip_request_middleware():
def app(environ, start_response):
assert_equal('Hello world!', environ['wsgi.input'].read(int(environ['CONTENT_LENGTH'])))
assert_equals('Hello world!', environ['wsgi.input'].read(int(environ['CONTENT_LENGTH'])))
gzcontent = StringIO()
f = gzip.GzipFile(fileobj=gzcontent, mode='w')
f.write('Hello world!')
......@@ -22,4 +22,3 @@ def test_gzip_request_middleware():
}
mw = GzipRequestMiddleware(app)
mw(environ, None)
# Copyright (C) 2011 Lukas Lalinsky
# Distributed under the MIT license, see the LICENSE file for details.
from nose.tools import *
from nose.tools import assert_equals, assert_raises, assert_true, assert_false
from acoustid.utils import singular, is_uuid, provider, is_foreignid
......@@ -26,4 +26,3 @@ def test_is_foreignid():
def test_provider():
assert_equals('foo', provider('foo')())
from nose.tools import assert_equal
from acoustid.web import db
from flask import request_finished
from tests import make_web_application
app = None
......
......@@ -15,8 +15,12 @@ passenv = ACOUSTID_TEST_*
basepython = python2
skip_install = true
deps = flake8
commands = python2 -m flake8 acoustid/
commands = python2 -m flake8 acoustid/ tests/
[flake8]
ignore = E712,E128,W391
ignore = E128
max-line-length = 160
per-file-ignores =
tests/__init__.py:E501
tests/test_api_v1.py:E501
tests/test_pg.py:E231,E501
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