Skip to content

Commit e906ba3

Browse files
Daan Rosendalmdonadoni
authored andcommitted
feat(fixtures): add workflows owned by user1 (#113)
Related to reanahub/reana-client#680
1 parent 67421e9 commit e906ba3

2 files changed

Lines changed: 85 additions & 1 deletion

File tree

pytest_reana/fixtures.py

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ def sample_yadage_workflow_in_db(
797797
next(sample_workflow_workspace(relative_workspace_path))
798798
workflow = Workflow(
799799
id_=workflow_id,
800-
name="sample_serial_workflow_1",
800+
name="sample_yadage_workflow_1",
801801
owner_id=user0.id_,
802802
reana_specification=yadage_workflow_with_name["reana_specification"],
803803
operational_options={},
@@ -814,6 +814,47 @@ def sample_yadage_workflow_in_db(
814814
session.commit()
815815

816816

817+
@pytest.fixture()
818+
def sample_yadage_workflow_in_db_owned_by_user1(
819+
app,
820+
user1,
821+
session,
822+
yadage_workflow_with_name,
823+
sample_workflow_workspace,
824+
tmp_shared_volume_path,
825+
):
826+
"""Create a sample workflow in the database.
827+
828+
Scope: function
829+
830+
Adds a sample yadage workflow in the DB.
831+
"""
832+
from reana_db.models import Workflow
833+
834+
workflow_id = uuid4()
835+
relative_workspace_path = build_workspace_path(
836+
user1.id_, workflow_id, tmp_shared_volume_path
837+
)
838+
next(sample_workflow_workspace(relative_workspace_path))
839+
workflow = Workflow(
840+
id_=workflow_id,
841+
name="sample_yadage_workflow_2",
842+
owner_id=user1.id_,
843+
reana_specification=yadage_workflow_with_name["reana_specification"],
844+
operational_options={},
845+
type_=yadage_workflow_with_name["reana_specification"]["workflow"]["type"],
846+
logs="",
847+
workspace_path=relative_workspace_path,
848+
)
849+
session.add(workflow)
850+
session.commit()
851+
yield workflow
852+
for resource in workflow.resources:
853+
session.delete(resource)
854+
session.delete(workflow)
855+
session.commit()
856+
857+
817858
@pytest.fixture()
818859
def sample_serial_workflow_in_db(
819860
app,
@@ -855,6 +896,47 @@ def sample_serial_workflow_in_db(
855896
session.commit()
856897

857898

899+
@pytest.fixture()
900+
def sample_serial_workflow_in_db_owned_by_user1(
901+
app,
902+
user1,
903+
session,
904+
serial_workflow,
905+
sample_workflow_workspace,
906+
tmp_shared_volume_path,
907+
):
908+
"""Create a sample workflow in the database.
909+
910+
Scope: function
911+
912+
Adds a sample serial workflow in the DB.
913+
"""
914+
from reana_db.models import Workflow
915+
916+
workflow_id = uuid4()
917+
relative_workspace_path = build_workspace_path(
918+
user1.id_, workflow_id, tmp_shared_volume_path
919+
)
920+
next(sample_workflow_workspace(relative_workspace_path))
921+
workflow = Workflow(
922+
id_=workflow_id,
923+
name="sample_serial_workflow_2",
924+
owner_id=user1.id_,
925+
reana_specification=serial_workflow["reana_specification"],
926+
operational_options={},
927+
type_=serial_workflow["reana_specification"]["workflow"]["type"],
928+
logs="",
929+
workspace_path=relative_workspace_path,
930+
)
931+
session.add(workflow)
932+
session.commit()
933+
yield workflow
934+
for resource in workflow.resources:
935+
session.delete(resource)
936+
session.delete(workflow)
937+
session.commit()
938+
939+
858940
def sample_condition_for_starting_queued_workflows():
859941
"""Sample always true condition."""
860942
return True

pytest_reana/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@
2525
kerberos_user_secrets,
2626
no_db_user,
2727
sample_serial_workflow_in_db,
28+
sample_serial_workflow_in_db_owned_by_user1,
2829
sample_workflow_workspace,
2930
sample_yadage_workflow_in_db,
31+
sample_yadage_workflow_in_db_owned_by_user1,
3032
serial_workflow,
3133
session,
3234
snakemake_workflow_spec_loaded,

0 commit comments

Comments
 (0)