Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixtures: create/teardown resources #72

Merged
merged 2 commits into from
Oct 30, 2020
Merged
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
7 changes: 6 additions & 1 deletion pytest_reana/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def create_ninja_turtle()

"""
from reana_db.database import Session
from reana_db.models import Base
from reana_db.models import Base, Resource

engine = create_engine(base_app.config["SQLALCHEMY_DATABASE_URI"])
base_app.session.bind = engine
Expand All @@ -113,6 +113,7 @@ def create_ninja_turtle()
if not database_exists(engine.url):
create_database(engine.url)
Base.metadata.create_all(bind=engine)
Resource.initialise_default_resources()
yield base_app
Session.close() # close hanging connections
Base.metadata.drop_all(bind=engine)
Expand Down Expand Up @@ -476,6 +477,8 @@ def sample_yadage_workflow_in_db(
session.add(workflow)
session.commit()
yield workflow
for resource in workflow.resources:
session.delete(resource)
session.delete(workflow)
session.commit()

Expand Down Expand Up @@ -508,6 +511,8 @@ def sample_serial_workflow_in_db(
session.add(workflow)
session.commit()
yield workflow
for resource in workflow.resources:
session.delete(resource)
session.delete(workflow)
session.commit()

Expand Down
2 changes: 1 addition & 1 deletion pytest_reana/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

from __future__ import absolute_import, print_function

__version__ = "0.8.0a1"
__version__ = "0.8.0a2"