def test_missing_asset(self):
        """
        What happens when an asset could not be found.
        """
        app = make_app(config={
            'ASSETREV_BASE_URL': '//cdn.myapp.com/',
            'ASSETREV_BASE_PATH': 'foobar',
        })

        with app.test_request_context():
            with self.assertRaises(asset_url.missing) as ctx:
                asset_url('missing.js')

            self.assertEqual(ctx.exception.asset_file, 'missing.js')
    def test_static_path(self):
        app = make_app(static_url_path='/foobar')

        with app.test_request_context():
            self.assertEqual(
                asset_url('app.js'),
                'http://localhost/foobar/app.deadb33f.js'
            )
    def test_programmatic(self):
        """
        Progmattically getting the asset_url should work.
        """
        app = make_app()

        with app.test_request_context():
            self.assertEqual(
                asset_url('app.js'),
                'http://localhost/static/app.deadb33f.js'
            )
    def test_base_url(self):
        """
        The url for the assets could not be part of the flask routes.
        """
        app = make_app(config={
            'ASSETREV_BASE_URL': '//cdn.myapp.com/',
        })

        with app.test_request_context():
            self.assertEqual(
                asset_url('app.js'),
                '//cdn.myapp.com/app.deadb33f.js'
            )
    def test_base_directory(self):
        """
        Built assets can be in a subdirectory
        """
        app = make_app(config={
            'ASSETREV_BASE_PATH': 'foobar',
        })

        with app.test_request_context():
            self.assertEqual(
                asset_url('app.js'),
                'http://localhost/static/foobar/app.deadb33f.js'
            )