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_manifest_contents_loaded():
    contents = get_state().manifest_contents
    assert 2 == len(contents)
    assert 'image1-xyz.jpg' == contents['image1.jpg']