Пример #1
0
def test_invalid_client_key():
    "Ensures invalid API keys are properly trapped"

    api = AcoustID('this-should-never-work')

    with pytest.raises(exceptions.InvalidClientKey):
        api.track(DEMO_TRACK)
Пример #2
0
def test_bad_fingerprint():
    "Sends a request with a bad fingerprint"

    api = AcoustID(os.environ['ACOUSTID_KEY'])

    with pytest.raises(exceptions.InvalidFingerprint):
        api.fingerprint('no-way-this-works', 1337)
Пример #3
0
def test_single_mbid_search():
    "Ensures batch MBID-to-AcoustID search"

    api = AcoustID(os.environ['ACOUSTID_KEY'])
    resp = api.acoustids_for_mbid('b724b973-53e0-4bba-9e2f-9aab916165a8')

    assert type(resp) == list
Пример #4
0
def test_basic_fingerprint_search(fingerprint):
    "Tests a simple fingerprint search"

    api = AcoustID(os.environ['ACOUSTID_KEY'])
    resp = api.fingerprint(fingerprint, 291)

    assert type(resp) == list
Пример #5
0
def test_bad_track_id():
    "Sends a request with a bad track UUID"

    api = AcoustID(os.environ['ACOUSTID_KEY'])

    with pytest.raises(exceptions.InvalidUUID):
        resp = api.track('l-o-l')
Пример #6
0
def test_track_search_with_meta():
    "Tests a complex track search"

    api = AcoustID(os.environ['ACOUSTID_KEY'])
    resp = api.track(DEMO_TRACK, meta=('sources', 'recordings'))

    assert type(resp) == list
Пример #7
0
def test_basic_track_search():
    "Tests a simple track search"

    api = AcoustID(os.environ['ACOUSTID_KEY'])
    resp = api.track(DEMO_TRACK)

    assert type(resp) == list
Пример #8
0
def test_fingerprint_search_with_bad_duration(fingerprint):
    """Ensures the failure of a fingerprint request
    with a bad duration
    """

    api = AcoustID(os.environ['ACOUSTID_KEY'])

    with pytest.raises(exceptions.InvalidDuration):
        api.fingerprint(fingerprint, -1)

    with pytest.raises(exceptions.InvalidDuration):
        api.fingerprint(fingerprint, (0x8000))
Пример #9
0
def test_invalid_format():
    "Ensures API instance cannot be created with an invalid format"

    with pytest.raises(exceptions.UnknownFormat):
        api = AcoustID('bad-api-key', format='bson')