Commit bd75d207 authored by Lukáš Lalinský's avatar Lukáš Lalinský

Fix tests

parent 85cad1f5
......@@ -37,25 +37,19 @@ class APIHandler(v2.APIHandler):
return serialize_response(response_data, format)
class LookupHandlerParams(APIHandlerParams):
class LookupHandlerParams(v2.LookupHandlerParams):
duration_name = 'length'
def _parse_format(self, values):
self.format = FORMAT
def parse(self, values, conn):
super(LookupHandlerParams, self).parse(values, conn)
self._parse_client(values, conn)
self.meta = values.get('meta')
if self.meta:
self.meta = ['recordingids']
else:
self.meta = []
self.duration = values.get('length', type=int)
if not self.duration:
raise errors.MissingParameterError('length')
fingerprint_string = values.get('fingerprint')
if not fingerprint_string:
raise errors.MissingParameterError('fingerprint')
self.fingerprint = decode_fingerprint(fingerprint_string)
if not self.fingerprint:
raise errors.InvalidFingerprintError()
class LookupHandler(v2.LookupHandler):
......
......@@ -117,6 +117,8 @@ class APIHandler(Handler):
class LookupHandlerParams(APIHandlerParams):
duration_name = 'duration'
def _parse_query(self, values, suffix):
p = {}
p['index'] = (suffix or '')[1:]
......@@ -124,9 +126,9 @@ class LookupHandlerParams(APIHandlerParams):
if p['track_gid'] and not is_uuid(p['track_gid']):
raise errors.InvalidUUIDError('trackid' + suffix)
if not p['track_gid']:
p['duration'] = values.get('duration' + suffix, type=int)
p['duration'] = values.get(self.duration_name + suffix, type=int)
if not p['duration']:
raise errors.MissingParameterError('duration' + suffix)
raise errors.MissingParameterError(self.duration_name + suffix)
fingerprint_string = values.get('fingerprint' + suffix)
if not fingerprint_string:
raise errors.MissingParameterError('fingerprint' + suffix)
......@@ -365,7 +367,7 @@ class LookupHandler(APIHandler):
return results.itervalues()
def inject_m2(self, meta):
el_recording = self._inject_recording_ids_internal(True)
el_recording = self._inject_recording_ids_internal(True)[0]
metadata = lookup_metadata(self.conn, el_recording.keys(), load_releases=True)
last_recording_id = None
for item in metadata:
......
......@@ -75,8 +75,8 @@ def test_lookup_handler_params(conn):
params = LookupHandlerParams()
params.parse(values, conn)
assert_equals(1, params.application_id)
assert_equals(TEST_1_LENGTH, params.duration)
assert_equals(TEST_1_FP_RAW, params.fingerprint)
assert_equals(TEST_1_LENGTH, params.fingerprints[0]['duration'])
assert_equals(TEST_1_FP_RAW, params.fingerprints[0]['fingerprint'])
@with_database
......
......@@ -96,8 +96,8 @@ def test_lookup_handler_params(conn):
params.parse(values, conn)
assert_equals('json', params.format)
assert_equals(1, params.application_id)
assert_equals(TEST_1_LENGTH, params.duration)
assert_equals(TEST_1_FP_RAW, params.fingerprint)
assert_equals(TEST_1_LENGTH, params.fingerprints[0]['duration'])
assert_equals(TEST_1_FP_RAW, params.fingerprints[0]['fingerprint'])
class WebServiceErrorHandler(APIHandler):
......
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