Example #1
0
def test_url_for_without_serving_dist_root():
    """
    Some other server might be serving the files in the manifest.
    TODO: Figure out the best way to construct URLs with the
    ``MANIFEST_DOMAIN``.
    """
    state = get_state()
    state.serve_root = False
    state.domain = 'example.com'
    expected_url = 'http://example.com/dist/image1-xyz.jpg'
    assert expected_url == url_for('static', filename='image1.jpg')
Example #2
0
def test_manifest_endpoint_view_func():
    target = 'flask_manifest.send_from_directory'

    with current_app.test_client() as client:
        with mock.patch(target) as mock_send_file:
            mock_send_file.return_value = 'contents'
            response = client.get(url_for('static', filename='image1.jpg'))

    state = get_state()
    mock_send_file.assert_called_once_with(state.root, 'image1-xyz.jpg',
                                           cache_timeout=FOREVER)
    assert 'contents' == response.data
Example #3
0
def test_url_for_fallback_to_flask_url_for():
    """
    If the ``filename`` isn't present in the manifest contents,
    the normal static URL should be returned.
    """
    assert '/static/image3.jpg' == url_for('static', filename='image3.jpg')
Example #4
0
def test_url_for():
    values = {'filename': 'image1.jpg'}
    assert '/dist/image1-xyz.jpg' == url_for('static', **values)