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