コード例 #1
0
 def test_compile_warns_on_missing_rule(self):
     app = Flask('missing_rule')
     make_static = MakeStatic(app)
     with catch_warnings(record=True) as warnings:
         make_static.compile()
     self.assertEqual(len(warnings), 1)
     self.assertTrue(issubclass(warnings[-1].category, RuleMissing))
     self.assertEqual(str(warnings[-1].message),
                      'cannot find a rule for foo.css')
コード例 #2
0
 def test_compile_warns_on_missing_rule(self):
     app = Flask('missing_rule')
     make_static = MakeStatic(app)
     with catch_warnings(record=True) as warnings:
         make_static.compile()
     self.assertEqual(len(warnings), 1)
     self.assertTrue(issubclass(warnings[-1].category, RuleMissing))
     self.assertEqual(str(warnings[-1].message),
                      'cannot find a rule for foo.css')
コード例 #3
0
 def make_static(self, import_name, config=None):
     app = Flask(import_name)
     if config is not None:
         app.config.update(config)
     make_static = MakeStatic(app)
     watcher = make_static.watch(sleep=0.01)
     try:
         yield app, make_static
     finally:
         watcher.stop()
コード例 #4
0
 def make_static(self, import_name, config=None):
     app = Flask(import_name)
     if config is not None:
         app.config.update(config)
     make_static = MakeStatic(app)
     watcher = make_static.watch(sleep=0.01)
     try:
         yield app, make_static
     finally:
         watcher.stop()
コード例 #5
0
 def make_static_in_app_context(self, import_name, config=None):
     app = Flask(import_name)
     if config is not None:
         app.config.update(config)
     make_static = MakeStatic()
     make_static.init_app(app)
     with app.app_context():
         watcher = make_static.watch(sleep=0.01)
         try:
             yield app, make_static
         finally:
             watcher.stop()
コード例 #6
0
 def make_static_in_app_context(self, import_name, config=None):
     app = Flask(import_name)
     if config is not None:
         app.config.update(config)
     make_static = MakeStatic()
     make_static.init_app(app)
     with app.app_context():
         watcher = make_static.watch(sleep=0.01)
         try:
             yield app, make_static
         finally:
             watcher.stop()
コード例 #7
0
    def test_compile(self):
        app = Flask('working')
        make_static = MakeStatic(app)
        make_static.compile()

        # ensure that app is not patched and assets are not compiled on demand
        app = Flask('working')
        client = app.test_client()
        with closing(client.get('/static/foo')) as response:
            self.assertEqual(response.status_code, 200)

        with closing(client.get('/static/spam')) as response:
            self.assertEqual(response.status_code, 200)

        with closing(client.get('/static/bar')) as response:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.data, b'abc\ndef\n')

        with closing(client.get('/static/eggs.css')) as response:
            self.assertEqual(response.status_code, 200)
コード例 #8
0
    def test_compile(self):
        app = Flask('working')
        make_static = MakeStatic(app)
        make_static.compile()

        # ensure that app is not patched and assets are not compiled on demand
        app = Flask('working')
        client = app.test_client()
        with closing(client.get('/static/foo')) as response:
            self.assertEqual(response.status_code, 200)

        with closing(client.get('/static/spam')) as response:
            self.assertEqual(response.status_code, 200)

        with closing(client.get('/static/bar')) as response:
            self.assertEqual(response.status_code, 200)
            self.assertEqual(response.data, b'abc\ndef\n')

        with closing(client.get('/static/eggs.css')) as response:
            self.assertEqual(response.status_code, 200)
コード例 #9
0
 def test_compile_factory_pattern_without_app_context(self):
     app = Flask('working')
     make_static = MakeStatic()
     make_static.init_app(app)
     self.assertRaises(RuntimeError, make_static.compile)
コード例 #10
0
 def test_compile_factory_pattern_without_app_context(self):
     app = Flask('working')
     make_static = MakeStatic()
     make_static.init_app(app)
     self.assertRaises(RuntimeError, make_static.compile)