Beispiel #1
0
    def test_register_blueprint(self):
        self.assertIn('dropbox', app.blueprints)
        old_blueprint = app.blueprints['dropbox']

        rules = [rule for rule in app.url_map._rules if rule.endpoint.startswith('dropbox.')]
        self.assertEqual(len(rules), 2)

        dropbox_obj = Dropbox(app)
        self.assertRaises(AssertionError,
                          dropbox_obj.register_blueprint,
                          url_prefix='/dbox')

        del app.blueprints['dropbox']
        dropbox_obj.register_blueprint(url_prefix='/dbox')

        rules = [rule for rule in app.url_map._rules if rule.endpoint.startswith('dropbox.')]
        self.assertEqual(len(rules), 4)

        self.assertIn('dropbox', app.blueprints)
        app.blueprints['dropbox'] = old_blueprint
Beispiel #2
0
    def test_register_blueprint(self):
        self.assertIn('dropbox', app.blueprints)
        old_blueprint = app.blueprints['dropbox']

        rules = filter(lambda rule: rule.endpoint.startswith('dropbox.'),
                       app.url_map._rules)
        self.assertEqual(len(rules), 2)

        dropbox_obj = Dropbox(app)
        self.assertRaises(AssertionError,
                          dropbox_obj.register_blueprint,
                          url_prefix='/dbox')

        del app.blueprints['dropbox']
        dropbox_obj.register_blueprint(url_prefix='/dbox')

        rules = filter(lambda rule: rule.endpoint.startswith('dropbox.'),
                       app.url_map._rules)
        self.assertEqual(len(rules), 4)

        self.assertIn('dropbox', app.blueprints)
        app.blueprints['dropbox'] = old_blueprint
Beispiel #3
0
import sys

from flask import Flask
from flask.ext.dropbox import Dropbox
from flask.ext.lazyviews import LazyViews
from flask.ext.script import Manager

from . import settings

# Initialize and configure Flask app
app = Flask(__name__)
app.config.from_object(settings)

# Setup Dropbox and script extensions
dropbox = Dropbox(app)
dropbox.register_blueprint(url_prefix='/dropbox')
manager = Manager(app)

# Add test project views
views = LazyViews(app, 'testapp.views')
views.add('/', 'home')
views.add('/delete/<path:filename>', 'delete')
views.add('/download/<path:filename>', 'download', endpoint='download')
views.add('/files', 'files')
views.add('/media/<path:filename>',
          'download',
          defaults={'media': True},
          endpoint='media')
views.add('/session/clear', 'session_clear')
views.add('/session/dump', 'session_dump')
views.add('/success/<path:filename>', 'success')
from flask import Flask
from flask.ext.dropbox import Dropbox
from flask.ext.lazyviews import LazyViews
from flask.ext.script import Manager

import settings


# Initialize and configure Flask app
app = Flask(__name__)
app.config.from_object(settings)

# Setup Dropbox and script extensions
dropbox = Dropbox(app)
dropbox.register_blueprint(url_prefix='/dropbox')
manager = Manager(app)

# Add test project views
views = LazyViews(app, 'testapp.views')
views.add('/', 'home')
views.add('/delete/<path:filename>', 'delete')
views.add('/download/<path:filename>', 'download', endpoint='download')
views.add('/files', 'files')
views.add('/media/<path:filename>',
          'download',
          defaults={'media': True},
          endpoint='media')
views.add('/session/clear', 'session_clear')
views.add('/session/dump', 'session_dump')
views.add('/success/<path:filename>', 'success')