Exemple #1
0
    def test_returns_document_with_hal_document(self):
        app = Flask(__name__)
        with app.test_request_context():
            d = document.Document()
            r = HALResponse.force_type(d, {})

        expected = json.dumps({'_links': {'self': {'href': '/'}}})

        assert isinstance(r, Response)
        assert r.headers['Content-Type'] == 'application/hal+json'
        assert r.data.decode("utf-8") == expected
Exemple #2
0
    def test_returns_document_with_hal_document(self):
        app = Flask(__name__)
        with app.test_request_context():
            d = document.Document()
            r = HALResponse.force_type(d, {})

        expected = json.dumps({
            '_links': {
                'self': {
                    'href': '/'
                }
            }
        })

        assert isinstance(r, Response)
        assert r.headers['Content-Type'] == 'application/hal+json'
        assert r.data.decode("utf-8") == expected
Exemple #3
0
    def test_returns_standard_response(self):
        r = HALResponse.force_type(Response('foo'), {})

        assert isinstance(r, Response)
        assert r.headers['Content-Type'] == 'text/html; charset=utf-8'
        assert r.data.decode("utf-8") == 'foo'
Exemple #4
0
    def test_returns_standard_response(self):
        r = HALResponse.force_type(Response('foo'), {})

        assert isinstance(r, Response)
        assert r.headers['Content-Type'] == 'text/html; charset=utf-8'
        assert r.data.decode("utf-8") == 'foo'