Newer
Older

Nathan Hertz
committed
import pytest
from workspaces.capability.services.capability_info import CapabilityInfo
from workspaces.capability.services.interfaces import CapabilityInfoIF
from workspaces.workflow.services.interfaces import WorkflowInfoIF
from workspaces.workflow.services.workflow_info import WorkflowInfo

Daniel Lyons
committed
SESSION = create_session("SDM")
def get_workflow_info() -> WorkflowInfoIF:
"""Return a WorkflowInfo based on a real database connection"""

Daniel Lyons
committed
return WorkflowInfo(SESSION)
def get_capability_info() -> CapabilityInfoIF:
"""Return a CapabilityInfo based on a real database connection"""

Daniel Lyons
committed
return CapabilityInfo(SESSION)

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_get_requests_for_capability():
"""Ensure we can get all requests for a certain capability"""
info = get_capability_info()
info.create_capability("test_get_requests", None, 0)
info.create_capability_request("test_get_requests")
assert len(info.requests_for_capability("test_get_requests")) > 0

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
"""Ensure we can persist a workflow request"""
info = get_workflow_info()
null = info.lookup_workflow_definition("null")
req = info.create_workflow_request(null, {})
assert req.results_dir is not None

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_reading_workflows():
"""Ensure we can get workflows"""
info = get_workflow_info()
workflows = info.all_workflows()
assert len(workflows) > 0

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_reading_workflow_requests():
"""Ensure we can get workflow requests"""
info = get_workflow_info()
workflow_requests = info.all_workflow_requests()
assert len(workflow_requests) > 0

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_reading_capability():
"""Ensure we can get a capability"""
info = get_capability_info()
null = info.lookup_capability("null")
assert null is not None

Daniel Lyons
committed

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)

Daniel Lyons
committed
def test_capability_associated_to_workflow():

Nathan Hertz
committed
"""
Tests that the relationship between capability requests and workflows is sound
FIXME: Needs an assertion to actually test something
"""

Daniel Lyons
committed
cinfo = get_capability_info()
winfo = get_workflow_info()
req = cinfo.create_capability_request("null", {})
exec = cinfo.create_execution(req)
workflow_req = winfo.create_workflow_request(
winfo.lookup_workflow_definition("null"), {}
)
exec.current_workflow_request = workflow_req
SESSION.add(exec)

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_download_capability_persisted():
"""
Tests that the download capability is successfully added by its alembic upgrade
"""
cinfo = get_capability_info()
capability = cinfo.lookup_capability("download")
assert capability.name == "download"

Nathan Hertz
committed
@pytest.mark.skip(
reason="This test queries the database, making it an integration test and unsuitable for CI."
)
def test_download_workflow_persisted():
"""
Tests that the download workflow is successfully added by its alembic upgrade
"""
winfo = get_workflow_info()
workflow = winfo.lookup_workflow_definition("download")
templates = winfo.lookup_workflow_templates_for("download")
assert workflow.workflow_name == "download"
assert len(templates) == 3