Exemplo n.º 1
0
    def setUp(self):
        super(FileAssetTestCase, self).setUp()

        # create a temporary folder used as the 'static' folder of the Flask
        # application
        static_folder = tempfile.mkdtemp()
        self.static_folder = static_folder

        # initialize the flask app
        app = flask.Flask(__name__, static_folder=static_folder)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # create a temporary file
        fd, filename = tempfile.mkstemp(dir=static_folder)
        os.write(fd, self.css_content.encode('utf-8'))
        os.close(fd)
        self.filename = os.path.basename(filename)

        # create a FileAsset object
        self.asset = FileAsset(self.filename, self.asset_processors)

        bundle = Bundle(name='test_bundle', assets=[self.asset])
        self.bundle = bundle
        self.compressor.register_bundle(bundle)
Exemplo n.º 2
0
 def setUp(self):
     # initialize the flask app
     app = flask.Flask(__name__)
     app.config['TESTING'] = True
     compressor = Compressor(app)
     self.app = app
     self.compressor = compressor
Exemplo n.º 3
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        def processor1(content):
            return content.replace('html', ' body ')

        def processor2(content):
            return content.replace(' body ', 'p ')

        def processor3(content):
            return content.replace(':red}', ':blue}')

        self.compressor.register_processor(processor1)
        self.compressor.register_processor(processor2)
        self.compressor.register_processor(processor3)

        css_content = 'html { background-color: red; } '
        self.asset1 = Asset(css_content,
                            processors=['processor1', 'processor2'])
        self.asset2 = Asset(css_content,
                            processors=['processor2', 'processor1'])
        self.bundle = Bundle(
            'test_bundle',
            assets=[self.asset1, self.asset2],
            processors=['cssmin', 'processor3'],
        )
Exemplo n.º 4
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # our bundle
        bundle = CSSBundle(
            name='test_bundle',
            assets=[
                Asset(content='first asset'),
                Asset(content='second asset'),
            ],
        )
        self.bundle = bundle

        compressor.register_bundle(bundle)
Exemplo n.º 5
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # our bundle
        bundle = Bundle(name='test_bundle')
        self.bundle = bundle
Exemplo n.º 6
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # some simple processors
        def test1(content):
            return "FOOBAR" + str(content)

        def test2(content):
            return str(content) + "BARFOO"

        compressor.register_processor(test1)
        compressor.register_processor(test2)

        # our bundle
        bundle = Bundle(name='test_bundle',
                        assets=[
                            Asset(content='first asset', processors=['test1']),
                            Asset(content='second asset')
                        ],
                        processors=['test2'])
        self.bundle = bundle

        compressor.register_bundle(bundle)
Exemplo n.º 7
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        # our processor function
        def test_processor(content):
            return "FOOBAR" + str(content)

        self.test_processor = test_processor
Exemplo n.º 8
0
    def setUp(self):
        # initialize the flask app
        app = flask.Flask(__name__)
        app.config['TESTING'] = True
        compressor = Compressor(app)
        self.app = app
        self.compressor = compressor

        self.css_content = '''
            html {
                background-color: red;
            }
        '''
        self.asset_processors = ['cssmin']
        self.asset = Asset(self.css_content, self.asset_processors)
        self.result_asset_content = 'html{background-color:red}'
Exemplo n.º 9
0
from flask import Flask
from flask_compressor import Compressor
from flask_material import Material
from flask_login import LoginManager
from pymongo import MongoClient
app = Flask(__name__, template_folder='../templates')
client = MongoClient('mongodb://localhost/')
database = client.calibrary
compressor = Compressor(app)
Material(app)
app.debug = True
login_manager = LoginManager()
login_manager.init_app(app)
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
import MiniProject.views