Example #1
0
def test_get_unsupported_encoder_with_fallback():
    codec = negotiate_encoder([CoreJSONCodec()], accept='application/csv, */*')
    assert isinstance(codec, CoreJSONCodec)
Example #2
0
def test_get_unsupported_encoder():
    with pytest.raises(NoCodecAvailable):
        negotiate_encoder([CoreJSONCodec()], 'application/csv')
Example #3
0
def test_get_underspecified_encoder():
    codec = negotiate_encoder([CoreJSONCodec()], accept='application/*')
    assert isinstance(codec, CoreJSONCodec)
Example #4
0
def test_get_accepted_encoder():
    codec = negotiate_encoder([CoreJSONCodec()],
                              accept='application/vnd.coreapi+json')
    assert isinstance(codec, CoreJSONCodec)
Example #5
0
def test_encoder_preference():
    codec = negotiate_encoder(
        [CoreJSONCodec()],
        accept='text/html; q=1.0, application/vnd.coreapi+json; q=1.0')
    assert isinstance(codec, CoreJSONCodec)
Example #6
0
def test_get_default_encoder():
    codec = negotiate_encoder([CoreJSONCodec()])
    assert isinstance(codec, CoreJSONCodec)