示例#1
0
    def test_app_with_template(self):
        from empty import app_factory, Empty

        app = app_factory('some-name', None, template_folder="templates")
        home_env = os.getenv('HOME')

        self.assertTrue(isinstance(app, Empty))
        self.assertTrue(home_env in app.template_folder)
        self.assertTrue('templates' in app.template_folder)
示例#2
0
    def test_date_output_format(self):
        app = app_factory(
            'myapp', EmptyConfig(),
            base_application=EmptyWithDateFilter)
        today = date(year=2015, month=10, day=5)

        with app.app_context():
            text = render_template_string("{{today|date}}", today=today)
            assert text == "2015/10/05"
示例#3
0
    def test_app_with_template(self):
        from empty import app_factory, Empty

        app = app_factory('some-name', None, template_folder="templates")
        home_env = os.getenv('HOME')

        self.assertTrue(isinstance(app, Empty))
        self.assertTrue(home_env in app.template_folder)
        self.assertTrue('templates' in app.template_folder)
示例#4
0
def test_date_filter():
    from datetime import date
    from flask import render_template_string

    today = date(year=2015, month=10, day=5)
    app = app_factory(object, 'myapp')

    with app.app_context():
        text = render_template_string("{{today|date}}", today=today)
        assert text == "2015/10/05"
示例#5
0
def test_datetime_filter():
    from datetime import datetime
    from flask import render_template_string

    now = datetime(year=2015, month=10, day=5, hour=5, minute=8, second=10)
    app = app_factory(object, 'myapp')

    with app.app_context():
        text = render_template_string("{{now|datetime}}", now=now)
        assert text == "2015/10/05 05:08"
示例#6
0
    def test_date_output_with_settings(self):
        from datetime import date

        today = date(year=2015, month=10, day=5)
        app = app_factory(
            'myapp',
            EmptyConfig(date_format='%d/%m/%Y'),
            base_application=EmptyWithDateFilter)

        with app.app_context():
            text = render_template_string("{{today|date}}", today=today)
            assert text == "05/10/2015"
示例#7
0
def test_datetime_filter_with_settings():
    from datetime import datetime
    from flask import render_template_string

    class Config:
        DATETIME_FORMAT = '%d/%m/%Y %H:%M'

    now = datetime(year=2015, month=10, day=5, hour=5, minute=8, second=10)
    app = app_factory(Config, 'myapp')

    with app.app_context():
        text = render_template_string("{{now|datetime}}", now=now)
        assert text == "05/10/2015 05:08"
示例#8
0
def test_date_filter_with_settings():
    from datetime import date
    from flask import render_template_string

    class Config:
        DATE_FORMAT = '%d/%m/%Y'

    today = date(year=2015, month=10, day=5)
    app = app_factory(Config, 'myapp')

    with app.app_context():
        text = render_template_string("{{today|date}}", today=today)
        assert text == "05/10/2015"
示例#9
0
    def test_datetime_filter_with_settings(self):
        now = datetime(
            year=2015,
            month=10,
            day=5,
            hour=5,
            minute=8,
            second=10)
        app = app_factory(
            'myapp',
            EmptyConfig(datetime_format='%d/%m/%Y %H:%M'),
            base_application=EmptyWithDatetimeFilter)

        with app.app_context():
            text = render_template_string("{{now|datetime}}", now=now)
            assert text == "05/10/2015 05:08"
示例#10
0
    def test_datetime_output_format(self):
        app = app_factory(
            'myapp', EmptyConfig(),
            base_application=EmptyWithDatetimeFilter)

        now = datetime(
            year=2015,
            month=10,
            day=5,
            hour=5,
            minute=8,
            second=10
        )

        with app.app_context():
            text = render_template_string("{{now|datetime}}", now=now)
            assert text == "2015/10/05 05:08"
示例#11
0
from empty import app_factory
from main import App
import config
import traceback
import logging

try:
    # SPA setup; template_folder ignored;
    app = app_factory('app',
                      config,
                      template_folder=None,
                      base_application=App)
except Exception as e:
    logging.error(traceback.format_exc())
    raise e
示例#12
0
文件: myapp.py 项目: italomaia/empty
from empty import EmptyConfig
from empty import app_factory


app = app_factory('myapp', EmptyConfig())
示例#13
0
    def test_app_without_template(self):
        from empty import app_factory, Empty

        app = app_factory('some-name', None, template_folder=None)
        self.assertTrue(isinstance(app, Empty))
        self.assertEqual(app.template_folder, None)
示例#14
0
from empty import EmptyConfig
from empty import app_factory

app = app_factory('myapp', EmptyConfig())
示例#15
0
    def test_app_without_template(self):
        from empty import app_factory, Empty

        app = app_factory('some-name', None, template_folder=None)
        self.assertTrue(isinstance(app, Empty))
        self.assertEqual(app.template_folder, None)
示例#16
0
from empty import app_factory


class Config:
    pass


app = app_factory(Config, 'myapp')