2021-06-24 09:46:26 -05:00
|
|
|
"""Test graphviz functionality."""
|
|
|
|
import os
|
|
|
|
|
|
|
|
from incorporealcms import create_app
|
|
|
|
|
|
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
def app_with_pydot():
|
|
|
|
"""Create the test app, including the pydot extension."""
|
|
|
|
return create_app(instance_path=os.path.join(HERE, 'instance'),
|
|
|
|
test_config={'MARKDOWN_EXTENSIONS': ['incorporealcms.mdx.pydot']})
|
|
|
|
|
|
|
|
|
|
|
|
def test_functional_initialization():
|
|
|
|
"""Test initialization with the graphviz config."""
|
|
|
|
app = app_with_pydot()
|
|
|
|
assert app is not None
|
|
|
|
|
|
|
|
|
|
|
|
def test_graphviz_is_rendered():
|
|
|
|
"""Initialize the app with the graphviz extension and ensure it does something."""
|
|
|
|
app = app_with_pydot()
|
|
|
|
client = app.test_client()
|
|
|
|
|
|
|
|
response = client.get('/test-graphviz')
|
|
|
|
assert response.status_code == 200
|
|
|
|
assert b'~~~pydot' not in response.data
|
|
|
|
assert b'data:image/png;base64' in response.data
|
2021-06-24 11:37:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
def test_invalid_graphviz_is_not_rendered():
|
|
|
|
"""Check that invalid graphviz doesn't blow things up."""
|
|
|
|
app = app_with_pydot()
|
|
|
|
client = app.test_client()
|
|
|
|
|
|
|
|
response = client.get('/test-invalid-graphviz')
|
|
|
|
assert response.status_code == 500
|
|
|
|
assert b'INTERNAL SERVER ERROR' in response.data
|