incorporeal-cms/tests/test_factory.py

31 lines
1.1 KiB
Python

"""Test basic configuration stuff."""
import os
from incorporealcms import create_app
HERE = os.path.dirname(os.path.abspath(__file__))
def test_config():
"""Test create_app without passing test config."""
instance_path = os.path.join(HERE, 'instance')
assert not create_app(instance_path=instance_path).testing
assert create_app(instance_path=instance_path, test_config={"TESTING": True}).testing
def test_title_override():
"""Test that a configuration with a specific title overrides the default."""
instance_path = os.path.join(HERE, 'instance')
app = create_app(instance_path=instance_path, test_config={'TITLE_SUFFIX': 'suou.net'})
client = app.test_client()
response = client.get('/no-title')
assert response.status_code == 200
assert b'<title>suou.net</title>' in response.data
def test_media_file_access(client):
"""Test that media files are served, and properly."""
response = client.get('/media/favicon.png')
assert response.status_code == 200
assert response.headers['content-type'] == 'image/png'