def test_head_etag(self, model): """Test correctness of HEAD request processing for {}""" obj = factories.get_model_factory(model.__name__)() response = self.api.head(model, obj.id) self.assert200(response) self.assertEqual(response.data, "") exp_etag = common.etag(getattr(obj, "updated_at"), common.get_info(obj)) self.assertEqual(response.headers.get("Etag"), exp_etag)
def json_success_response(response_object, last_modified=None, status=200): """Build a 200-response with metadata headers.""" headers = [ ('Etag', etag(response_object)), ('Content-Type', 'application/json'), ] if last_modified is not None: headers.append(('Last-Modified', http_timestamp(last_modified))) return current_app.make_response( (as_json(response_object), status, headers), )