Files
galaxy/test/unit/test_markdown_validate.py
T
John Chilton ad650897d6 Implement workflow invocation reports.
Implement markdown backend and frontend components as well generator plugin framework to allow customizable workflow invocation reports.

Architectural Choices on the Client

Old-style embedded objects vs components

In theory, this could make really nice use of excellent VueJS components for dataset display, dataset collection display, workflow display, etc.. These aren't available yet, we don't even really have Backbone stuff that exist very well outside history panels, so this re-uses "components" from Galaxy Pages for datasets and reuses the collection display for history panels as a stand-alone display for collections (I got this trick from DIsplayStructured.vue). This isn't ideal and I know that but at least reusing things this way will provide a path forward for migrating both pages and this new Markdown language (which could easily replace or co-exist with pages HTML someday) together seamlessly as the real modern components become available and doesn't increase the overall work needed to integrate newer style components. In fact, this might even be the impetus for creating and polishing more of these components.

markdown-it vs markdown-it-vue

I tried this with markdown-it-vue also but it added very little in terms of reducing client code, obscured entirely how to attach plugins to the markdown rendering process, and brought in many, many more extra packages that we don't need or want.

Given there is no representation of invocations in the GUI and not editor for reports config this is a bit challenging still. But here is goes:

- Source Galaxy's virtualenv.
- Login to a user and grab an API key, set in the following command:
- ``GALAXY_TEST_EXTERNAL=http://localhost:8080 GALAXY_TEST_USER_API_KEY=38175dfc69d9009992b69efcca8b209b pytest test/api/test_workflows.py::WorkflowsApiTestCase::test_workflow_invocation_report_custom``
- In the web browser go to http://localhost:8080/api/invocations and grab the latest invocation ID. Replace it in the follow query string.
- Navigate to http://localhost:8080/workflows/invocations/report?id=c887f1d0da42bdfe
2019-08-30 09:43:01 -04:00

56 lines
1.3 KiB
Python

from galaxy.managers.markdown_util import validate_galaxy_markdown
def assert_markdown_valid(markdown):
validate_galaxy_markdown(markdown)
def assert_markdown_invalid(markdown, at_line=None):
failed = False
try:
validate_galaxy_markdown(markdown)
except Exception as e:
failed = True
if at_line is not None:
assert "Invalid line %d" % (at_line + 1) in str(e)
assert failed, "Expected markdown [%s] to fail validation but it did not." % markdown
def test_markdown_validation():
assert_markdown_valid("""
hello world
""")
assert_markdown_valid("""
hello ``world``
Here is some more text.
```
import <stdio>
printf('hello')
```
""")
# assert no container close at bad location
assert_markdown_invalid("""
hello ``world``
:::
""", at_line=3)
# assert valid container is fine.
assert_markdown_valid("""
::: job_metrics job_id=THISFAKEID
:::
""")
# assert valid container is fine.
assert_markdown_valid("""
::: job_metrics job_id=THISFAKEID
:::""")
# assert valid containers require container close
assert_markdown_invalid("""
::: job_metrics job_id=THISFAKEID
foo
""", at_line=2)
# assert valid containers require container close, even at end...
assert_markdown_invalid("""
::: job_metrics job_id=THISFAKEID""")