コード例 #1
0
    def create_client(self, presentation_root, media_root, config):
        app = FlaskReveal('flask_reveal')

        app.load_user_config(presentation_root, media_root, config)
        app.config['TESTING'] = True

        return app.test_client()
コード例 #2
0
ファイル: start.py プロジェクト: IgitDanny/flask-reveal
    def run(self, args=None):
        self.parse_args(args)

        app = FlaskReveal('flask_reveal')

        app.start(self.path, media_root=self.media,
                  config=self.config, debug=self.debug)
コード例 #3
0
ファイル: test_base.py プロジェクト: chrmorais/flask-reveal
    def setUp(self):
        self.app = FlaskReveal('flask_reveal')

        self.app.config['TESTING'] = True

        fd, self.config = tempfile.mkstemp('.py')

        os.close(fd)
コード例 #4
0
    def run(self, args=None):
        self.parse_args(args)

        app = FlaskReveal('flask_reveal')

        app.start(self.path,
                  media_root=self.media,
                  config=self.config,
                  debug=self.debug)
コード例 #5
0
ファイル: test_base.py プロジェクト: IgitDanny/flask-reveal
    def setUp(self):
        self.app = FlaskReveal('flask_reveal')

        self.app.config['TESTING'] = True

        fd, self.config = tempfile.mkstemp('.py')

        os.close(fd)
コード例 #6
0
    def create_client(self, presentation_root, media_root, config):
        app = FlaskReveal('flask_reveal')

        app.load_user_config(presentation_root, media_root, config)
        app.config['TESTING'] = True

        return app.test_client()
コード例 #7
0
ファイル: test_base.py プロジェクト: IgitDanny/flask-reveal
class BaseAppTestCase(unittest.TestCase):

    def setUp(self):
        self.app = FlaskReveal('flask_reveal')

        self.app.config['TESTING'] = True

        fd, self.config = tempfile.mkstemp('.py')

        os.close(fd)

    def tearDown(self):
        os.remove(self.config)

    def test_start_invalid_config(self):
        self.assertRaises(FileNotFoundError,
                          self.app.start,
                          '', '', 'invalid_file')

    def test_current_app(self):
        with self.app.app_context():
            self.assertEqual(current_app.name, 'flask_reveal')

    def test_blueprint_loading(self):
        with self.app.app_context():
            self.assertDictEqual(current_app.blueprints,
                                 {'reveal': reveal_blueprint})

    def test_default_config_loading(self):
        with self.app.app_context():
            self.assertDictEqual(current_app.config['REVEAL_META'],
                                 REVEAL_META)
            self.assertDictEqual(current_app.config['REVEAL_CONFIG'],
                                 REVEAL_CONFIG)

    def test_user_config_loading(self):
        with open(self.config, 'w') as config:
            config.write('TEST_VAR = "TEST"')

        self.app.load_user_config('', '', self.config)

        with self.app.app_context():
            self.assertEqual(current_app.config['TEST_VAR'], 'TEST')

    def test_user_config_loading_invalid_config_file(self):
        self.assertRaises(FileNotFoundError,
                          self.app.load_user_config,
                          '', '', 'invalid_file')
コード例 #8
0
ファイル: test_base.py プロジェクト: chrmorais/flask-reveal
class BaseAppTestCase(unittest.TestCase):
    def setUp(self):
        self.app = FlaskReveal('flask_reveal')

        self.app.config['TESTING'] = True

        fd, self.config = tempfile.mkstemp('.py')

        os.close(fd)

    def tearDown(self):
        os.remove(self.config)

    def test_start_invalid_config(self):
        self.assertRaises(FileNotFoundError, self.app.start, '', '',
                          'invalid_file')

    def test_current_app(self):
        with self.app.app_context():
            self.assertEqual(current_app.name, 'flask_reveal')

    def test_blueprint_loading(self):
        with self.app.app_context():
            self.assertDictEqual(current_app.blueprints,
                                 {'reveal': reveal_blueprint})

    def test_default_config_loading(self):
        with self.app.app_context():
            self.assertDictEqual(current_app.config['REVEAL_META'],
                                 REVEAL_META)
            self.assertDictEqual(current_app.config['REVEAL_CONFIG'],
                                 REVEAL_CONFIG)

    def test_user_config_loading(self):
        with open(self.config, 'w') as config:
            config.write('TEST_VAR = "TEST"')

        self.app.load_user_config('', '', self.config)

        with self.app.app_context():
            self.assertEqual(current_app.config['TEST_VAR'], 'TEST')

    def test_user_config_loading_invalid_config_file(self):
        self.assertRaises(FileNotFoundError, self.app.load_user_config, '', '',
                          'invalid_file')