Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bullseye
FROM debian:trixie
ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH /app/
ENV DEBIAN_FRONTEND noninteractive
Expand Down
2 changes: 1 addition & 1 deletion api/build_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -eu
export DEBIAN_FRONTEND=noninteractive

echo 'deb http://deb.debian.org/debian bullseye-backports main' \
echo 'deb http://deb.debian.org/debian trixie-backports main' \
> /etc/apt/sources.list.d/backports.list

# Install ca-certificates and gnupg first
Expand Down
7 changes: 4 additions & 3 deletions api/ooniapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
import datetime
import logging
import os
import json
import re
import sys
from collections import deque

from flask import Flask, json
from flask import Flask

from flask_cors import CORS # debdeps: python3-flask-cors

Expand All @@ -32,7 +33,7 @@
APP_DIR = os.path.dirname(__file__)


class FlaskJSONEncoder(json.JSONEncoder):
class JSONEncoderWithDates(json.JSONEncoder):
# Special JSON encoder that handles dates
def default(self, o):
if isinstance(o, datetime.datetime):
Expand Down Expand Up @@ -176,7 +177,7 @@ def create_app(*args, testmode=False, **kw):
from ooniapi import views

app = Flask(__name__)
app.json_encoder = FlaskJSONEncoder
app.json_encoder = JSONEncoderWithDates

# Order matters
init_app(app, testmode=testmode)
Expand Down
2 changes: 1 addition & 1 deletion api/ooniapi/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from flask import current_app

from sqlalchemy.dialects import postgresql
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import declarative_base
from sqlalchemy.sql.elements import TextClause
from sqlalchemy.sql.selectable import Select

Expand Down
15 changes: 8 additions & 7 deletions api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def app():
return app


@pytest.yield_fixture
@pytest.fixture
def client(app):
"""
Overriding the `client` fixture from pytest_flask to fix this bug:
Expand All @@ -37,12 +37,13 @@ def client(app):
with app.test_client() as client:
yield client

while True:
top = flask._request_ctx_stack.top
if top is not None and top.preserved:
top.pop()
else:
break
# deprecated name _request_ctx_stack and marked as not a bug on issue #42
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From pytest-dev/pytest-flask#42, this workaround is not recommended.

#while True:
# top = flask._request_ctx_stack.top
# if top is not None and top.preserved:
# top.pop()
# else:
# break


@pytest.fixture(autouse=True)
Expand Down