Ejemplo n.º 1
0
def test_submit_handler_foreignid(conn):
    values = {'format': 'json', 'client': 'app1key', 'user': '******',
        'duration': str(TEST_1_LENGTH), 'fingerprint': TEST_1_FP, 'bitrate': 192,
        'foreignid': 'foo:123', 'fileformat': 'FLAC'}
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(connect=provider(conn))
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {"status": "ok"}
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(tables.submission.c.id.desc()).limit(1)
    submission = conn.execute(query).fetchone()
    assert_equals(None, submission['mbid'])
    assert_equals(None, submission['puid'])
    assert_equals(1, submission['foreignid_id'])
    assert_equals(1, submission['format_id'])
    assert_equals(192, submission['bitrate'])
    assert_equals(TEST_1_FP_RAW, submission['fingerprint'])
    assert_equals(TEST_1_LENGTH, submission['length'])
    query = tables.foreignid_vendor.select().order_by(tables.foreignid_vendor.c.id.desc()).limit(1)
    row = conn.execute(query).fetchone()
    assert_equals(1, row['id'])
    assert_equals('foo', row['name'])
    query = tables.foreignid.select().order_by(tables.foreignid.c.id.desc()).limit(1)
    row = conn.execute(query).fetchone()
    assert_equals(1, row['id'])
    assert_equals(1, row['vendor_id'])
    assert_equals('123', row['name'])
Ejemplo n.º 2
0
def test_submit_handler_with_meta(conn):
    values = {'format': 'json', 'client': 'app1key', 'user': '******',
        'duration': str(TEST_1_LENGTH), 'fingerprint': TEST_1_FP, 'bitrate': 192,
        'mbid': 'b9c05616-1874-4d5d-b30e-6b959c922d28', 'fileformat': 'FLAC',
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'albumartist': 'Prodigy',
        'trackno': '2',
        'discno': '3',
        'year': '2030'
    }
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(connect=provider(conn))
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {"status": "ok"}
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(tables.submission.c.id.desc()).limit(1)
    submission = conn.execute(query).fetchone()
    assert_equals('b9c05616-1874-4d5d-b30e-6b959c922d28', submission['mbid'])
    assert_equals(1, submission['meta_id'])
    row = conn.execute("SELECT * FROM meta WHERE id=1").fetchone()
    expected = {
        'id': 1,
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'album_artist': 'Prodigy',
        'track_no': 2,
        'disc_no': 3,
        'year': 2030
    }
    assert_equals(expected, dict(row))
Ejemplo n.º 3
0
def test_submit_handler_foreignid(ctx):
    # type: (ScriptContext) -> None
    values = {
        'format': 'json',
        'client': 'app1key',
        'user': '******',
        'duration': str(TEST_1_LENGTH),
        'fingerprint': TEST_1_FP,
        'bitrate': 192,
        'foreignid': 'foo:123',
        'fileformat': 'FLAC'
    }
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(ctx)
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {
        u'status': u'ok',
        u'submissions': [{
            u'status': u'pending',
            u'id': 1
        }]
    }
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(
        tables.submission.c.id.desc()).limit(1)
    submission = ctx.db.get_ingest_db().execute(query).fetchone()
    assert_equals(None, submission['mbid'])
    assert_equals(None, submission['puid'])
    assert_equals('foo:123', submission['foreignid'])
    assert_equals('FLAC', submission['format'])
    assert_equals(192, submission['bitrate'])
    assert_equals(TEST_1_FP_RAW, submission['fingerprint'])
    assert_equals(TEST_1_LENGTH, submission['length'])
Ejemplo n.º 4
0
def test_submit_handler_puid(conn):
    values = {
        'format': 'json',
        'client': 'app1key',
        'user': '******',
        'duration': str(TEST_1_LENGTH),
        'fingerprint': TEST_1_FP,
        'bitrate': 192,
        'puid': 'b9c05616-1874-4d5d-b30e-6b959c922d28',
        'fileformat': 'FLAC'
    }
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(connect=provider(conn))
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {"status": "ok"}
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(
        tables.submission.c.id.desc()).limit(1)
    submission = conn.execute(query).fetchone()
    assert_equals(None, submission['mbid'])
    assert_equals('b9c05616-1874-4d5d-b30e-6b959c922d28', submission['puid'])
    assert_equals(1, submission['format_id'])
    assert_equals(192, submission['bitrate'])
    assert_equals(TEST_1_FP_RAW, submission['fingerprint'])
    assert_equals(TEST_1_LENGTH, submission['length'])
Ejemplo n.º 5
0
def test_submit_handler_with_meta(ctx):
    # type: (ScriptContext) -> None
    values = {
        'format': 'json',
        'client': 'app1key',
        'user': '******',
        'duration': str(TEST_1_LENGTH),
        'fingerprint': TEST_1_FP,
        'bitrate': 192,
        'mbid': 'b9c05616-1874-4d5d-b30e-6b959c922d28',
        'fileformat': 'FLAC',
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'albumartist': 'Prodigy',
        'trackno': '2',
        'discno': '3',
        'year': '2030'
    }
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(ctx)
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {
        u'status': u'ok',
        u'submissions': [{
            u'status': u'pending',
            u'id': 1
        }]
    }
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(
        tables.submission.c.id.desc()).limit(1)
    submission = ctx.db.get_ingest_db().execute(query).fetchone()
    assert_equals('b9c05616-1874-4d5d-b30e-6b959c922d28', submission['mbid'])
    assert_equals(None, submission['meta_id'])
    assert_equals(None, submission['meta_gid'])
    expected_meta = {
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'album_artist': 'Prodigy',
        'track_no': 2,
        'disc_no': 3,
        'year': 2030
    }
    assert_equals(expected_meta, submission['meta'])
Ejemplo n.º 6
0
def test_submit_handler_with_meta(conn):
    values = {
        'format': 'json',
        'client': 'app1key',
        'user': '******',
        'duration': str(TEST_1_LENGTH),
        'fingerprint': TEST_1_FP,
        'bitrate': 192,
        'mbid': 'b9c05616-1874-4d5d-b30e-6b959c922d28',
        'fileformat': 'FLAC',
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'albumartist': 'Prodigy',
        'trackno': '2',
        'discno': '3',
        'year': '2030'
    }
    builder = EnvironBuilder(method='POST', data=values)
    handler = SubmitHandler(connect=provider(conn))
    resp = handler.handle(Request(builder.get_environ()))
    assert_equals('application/json; charset=UTF-8', resp.content_type)
    expected = {"status": "ok"}
    assert_json_equals(expected, resp.data)
    assert_equals('200 OK', resp.status)
    query = tables.submission.select().order_by(
        tables.submission.c.id.desc()).limit(1)
    submission = conn.execute(query).fetchone()
    assert_equals('b9c05616-1874-4d5d-b30e-6b959c922d28', submission['mbid'])
    assert_equals(1, submission['meta_id'])
    row = conn.execute("SELECT * FROM meta WHERE id=1").fetchone()
    expected = {
        'id': 1,
        'track': 'Voodoo People',
        'artist': 'The Prodigy',
        'album': 'Music For The Jitled People',
        'album_artist': 'Prodigy',
        'track_no': 2,
        'disc_no': 3,
        'year': 2030
    }
    assert_equals(expected, dict(row))