@@ -0,0 +1,2302 @@
+import pytest%0Aimport msgpack%0Afrom falcon import API, testing%0A%0Afrom pianodb.routes import ValidatorComponent, SongFinish%0A%0A%0ATOKEN = 'CB80CB12CC0F41FC87CA6F2AC989E27E'%0AAPI_PREFIX = '/api/v1'%0ASONGFINISH_ROUTE = %22%7BAPI_PREFIX%7D/songfinish%22.format(API_PREFIX=API_PREFIX)%0A%0A%0A@pytest.fixture(scope='module')%0Adef client():%0A%0A    api = API(middleware=ValidatorComponent())%0A    api.add_route(SONGFINISH_ROUTE, SongFinish(token=TOKEN))%0A%0A    return testing.TestClient(api)%0A%0A%0Adef test_songfinish_requires_auth_token(client):%0A    %22%22%22%0A    TODO: Document this test.%0A    %22%22%22%0A%0A    expected = dict(%0A        title='Authentication required',%0A        description='Missing or invalid authentication token',%0A    )%0A%0A    result = client.simulate_post(path=SONGFINISH_ROUTE)%0A%0A    assert result.status_code == 401  # HTTP 401 Unauthorized%0A    assert result.json == expected%0A%0A%0Adef test_songfinish_requires_msgpack_payloads(client):%0A    %22%22%22%0A    TODO: Document this test.%0A    %22%22%22%0A%0A    expected = dict(%0A        title='Unsupported media type',%0A        description='Payload must be msgpack',%0A    )%0A%0A    result = client.simulate_post(path=SONGFINISH_ROUTE,%0A                                  headers=%7B%0A                                      'X-Auth-Token': TOKEN,%0A                                  %7D)%0A%0A    assert result.status_code == 415  # HTTP 415 Unsupported Media Type%0A    assert result.json == expected%0A%0A%0Adef test_songfinish_requires_valid_msgpack_payloads(client):%0A    %22%22%22%0A    TODO: Document this test.%0A    %22%22%22%0A%0A    # A properly formatted payload would be b'%5Cx81%5Cxa6artist%5CxabJohn Cleese'%0A    malformed_msgpack = b'%5Cx82%5Cxa6artist%5CxabJohn Cleese'%0A%0A    expected = dict(%0A        title='Bad request',%0A        description='Could not unpack msgpack data',%0A    )%0A%0A    result = client.simulate_post(path=SONGFINISH_ROUTE,%0A                                  body=malformed_msgpack,%0A                                  headers=%7B%0A                                      'X-Auth-Token': TOKEN,%0A                                      'Content-Type': 'application/msgpack',%0A                                  %7D)%0A%0A    assert result.status_code == 400  # HTTP 400 Bad Request%0A    assert result.json == expected%0A%0A%0A# TODO: Test remaining branches and investigate msgpack.exceptions.ExtraData or%0A# UnicodeDecodeError errors when given a non-msgpack request body.%0A

Add initial Falcon API tests