Skip to content

Commit

Permalink
fixtures: move REANA-DB imports at fixture level
Browse files Browse the repository at this point in the history
* Avoids side effects when importing `pytest-reana` into REANA
  packages that do not depend on REANA-DB (e.g. REANA-Client)
  where incompatibilities such as using `f-strings` in REANA-DB
  and REANA-Client supporting Python2.7 are not compatible
  at import time.
  • Loading branch information
Diego Rodriguez committed Oct 14, 2020
1 parent dbd3c61 commit 33007ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pytest_reana/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from kubernetes import client
from mock import Mock, patch
from reana_commons.consumer import BaseConsumer
from reana_db.models import Base, User, Workflow
from reana_db.utils import build_workspace_path
from sqlalchemy import create_engine
from sqlalchemy.schema import CreateSchema
Expand Down Expand Up @@ -139,6 +138,8 @@ def test_default_user_exists(default)
"""
from reana_db.models import User

default_user_id = "00000000-0000-0000-0000-000000000000"
user = User.query.filter_by(id_=default_user_id).first()
if not user:
Expand Down Expand Up @@ -456,6 +457,8 @@ def sample_yadage_workflow_in_db(
Adds a sample yadage workflow in the DB.
"""
from reana_db.models import Workflow

workflow_id = uuid4()
relative_workspace_path = build_workspace_path(default_user.id_, workflow_id)
next(sample_workflow_workspace(relative_workspace_path))
Expand Down Expand Up @@ -486,6 +489,8 @@ def sample_serial_workflow_in_db(
Adds a sample serial workflow in the DB.
"""
from reana_db.models import Workflow

workflow_id = uuid4()
relative_workspace_path = build_workspace_path(default_user.id_, workflow_id)
next(sample_workflow_workspace(relative_workspace_path))
Expand Down

0 comments on commit 33007ba

Please sign in to comment.