Fix redefined-outer-name
This commit is contained in:
parent
d718ecf6d3
commit
a0e30b60b7
10 changed files with 98 additions and 98 deletions
|
|
@ -8,13 +8,13 @@ bp = Blueprint("tasks", __name__, url_prefix="/tasks")
|
|||
|
||||
|
||||
@bp.get("/result/<id>")
|
||||
def result(id: str) -> dict[str, object]:
|
||||
result = AsyncResult(id)
|
||||
ready = result.ready()
|
||||
def get_result(id: str) -> dict[str, object]:
|
||||
async_result = AsyncResult(id)
|
||||
ready = async_result.ready()
|
||||
return {
|
||||
"ready": ready,
|
||||
"successful": result.successful() if ready else None,
|
||||
"value": result.get() if ready else result.result,
|
||||
"successful": async_result.successful() if ready else None,
|
||||
"value": async_result.get() if ready else async_result.result,
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -22,17 +22,17 @@ def result(id: str) -> dict[str, object]:
|
|||
def add() -> dict[str, object]:
|
||||
a = request.form.get("a", type=int)
|
||||
b = request.form.get("b", type=int)
|
||||
result = tasks.add.delay(a, b)
|
||||
return {"result_id": result.id}
|
||||
task_result = tasks.add.delay(a, b)
|
||||
return {"result_id": task_result.id}
|
||||
|
||||
|
||||
@bp.post("/block")
|
||||
def block() -> dict[str, object]:
|
||||
result = tasks.block.delay()
|
||||
return {"result_id": result.id}
|
||||
task_result = tasks.block.delay()
|
||||
return {"result_id": task_result.id}
|
||||
|
||||
|
||||
@bp.post("/process")
|
||||
def process() -> dict[str, object]:
|
||||
result = tasks.process.delay(total=request.form.get("total", type=int))
|
||||
return {"result_id": result.id}
|
||||
task_result = tasks.process.delay(total=request.form.get("total", type=int))
|
||||
return {"result_id": task_result.id}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ def fixture_app():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
return app.test_client()
|
||||
def client(app_):
|
||||
return app_.test_client()
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ def app():
|
|||
# create a temporary file to isolate the database for each test
|
||||
db_fd, db_path = tempfile.mkstemp()
|
||||
# create the app with common test config
|
||||
app = create_app({"TESTING": True, "DATABASE": db_path})
|
||||
test_app = create_app({"TESTING": True, "DATABASE": db_path})
|
||||
|
||||
# create the database and load test data
|
||||
with app.app_context():
|
||||
with test_app.app_context():
|
||||
init_db()
|
||||
get_db().executescript(_data_sql)
|
||||
|
||||
yield app
|
||||
yield test_app
|
||||
|
||||
# close and remove the temporary database
|
||||
os.close(db_fd)
|
||||
|
|
@ -33,20 +33,20 @@ def app():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
def client(app_):
|
||||
"""A test client for the app."""
|
||||
return app.test_client()
|
||||
return app_.test_client()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def runner(app):
|
||||
def runner(app_):
|
||||
"""A test runner for the app's Click commands."""
|
||||
return app.test_cli_runner()
|
||||
return app_.test_cli_runner()
|
||||
|
||||
|
||||
class AuthActions:
|
||||
def __init__(self, client):
|
||||
self._client = client
|
||||
def __init__(self, client_obj):
|
||||
self._client = client_obj
|
||||
|
||||
def login(self, username="test", password="test"):
|
||||
return self._client.post(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue