Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
k-o-pshenichnikova committed Jan 10, 2024
1 parent 4e7126d commit 8008ef7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
4 changes: 0 additions & 4 deletions overhave/admin/views/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ def get_bdd_steps(self) -> dict[FeatureTypeName, dict[StepTypeName, list[BddStep
class FeatureView(ModelViewConfigured, FactoryViewUtilsMixin):
"""View for :class:`Feature` table."""

data_store = None

can_view_details = False

inline_models = (ScenarioInlineModelForm(db.Scenario),)
Expand Down Expand Up @@ -245,8 +243,6 @@ def edit_view(self) -> werkzeug.Response:

data = flask.request.form

FeatureView.data_store = data

logger.debug("Request data:\n%s", json.dumps(data))
run_scenario_action = data.get("run")
if not run_scenario_action:
Expand Down
19 changes: 8 additions & 11 deletions overhave/admin/views/scenario_test_run.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import logging
from typing import Any, cast
from typing import cast

import flask
import werkzeug
from flask_admin import expose
from flask_admin.model.helpers import get_mdict_item_or_list
from flask_login import current_user
from wtforms import Form, ValidationError

from overhave import db
from overhave.admin.views import FeatureView
from overhave.admin.views.base import ModelViewConfigured
from overhave.factory import get_admin_factory, get_test_execution_factory
from overhave.pytest_plugin import get_proxy_manager
Expand Down Expand Up @@ -72,15 +72,13 @@ def on_model_delete(self, model: db.TestRun) -> None:
raise ValidationError("Only test run initiator could delete test run result!")

@staticmethod
def _run_test(data: dict[str, Any], rendered: werkzeug.Response) -> werkzeug.Response:
scenario_id = data.get(f"{_SCENARIO_PREFIX}-id")
scenario_text = data.get(f"{_SCENARIO_PREFIX}-text")
if not scenario_id or not scenario_text:
flask.flash("Scenario information not requested.", category="error")
return rendered
def _run_test(rendered: werkzeug.Response) -> werkzeug.Response:
current_test_run_id = get_mdict_item_or_list(flask.request.args, "id")
factory = get_admin_factory()
with db.create_session() as session:
scenario = factory.scenario_storage.scenario_model_by_id(session=session, scenario_id=int(scenario_id))
scenario = factory.scenario_storage.scenario_model_by_id(
session=session, scenario_id=int(current_test_run_id)
)
test_run_id = factory.test_run_storage.create_testrun(scenario_id=scenario.id, executed_by=current_user.login)
if not factory.context.admin_settings.consumer_based:
proxy_manager = get_proxy_manager()
Expand All @@ -99,9 +97,8 @@ def _run_test(data: dict[str, Any], rendered: werkzeug.Response) -> werkzeug.Res
@expose("/details/", methods=("GET", "POST"))
def details_view(self) -> werkzeug.Response:
rendered: werkzeug.Response = super().details_view()
data = FeatureView.data_store

if flask.request.method == "POST":
return self._run_test(data, rendered)
return self._run_test(rendered)

return cast(werkzeug.Response, super().details_view())

0 comments on commit 8008ef7

Please sign in to comment.