Ejemplo n.º 1
0
def app(config_path):
    core.load_config(config_path)
    core.load_storage()
    core.load_session()
    core.load_wsgi()
    app = core.app
    return app
Ejemplo n.º 2
0
def app(config_path):
    config = ConfigParser.ConfigParser()

    if not os.path.exists(config_path):
        print('Error: "%s" file not exists.' % config_path)
        sys.exit(1)

    config.read(config_path)

    # Create storage
    storage_settings = {}
    for item in config.items('storage'):
        storage_settings[item[0]] = item[1]
    del storage_settings['type']

    # Flask webserver config
    if config.has_section('webserver') and config.get('webserver', 'host'):
        core.host = config.get('webserver', 'host')
    if config.has_section('webserver') and config.get('webserver', 'port'):
        core.port = config.get('webserver', 'port')
    if config.has_section('webserver') and config.get('webserver', 'debug'):
        if config.get('webserver', 'debug') in ['True', 'true']:
            core.debug = True
        else:
            core.debug = False

    storage_module = _load_storage(config.get('storage', 'type'))
    core.storage = storage_module
    core.storage_settings = storage_settings
    core.load_storage()
    core.load_wsgi()

    app = core.app
    return app
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest

from leselys import core


from flask import request

core.app.config['TESTING'] = True
core.load_config('config.ini')
core.load_storage()
core.load_session()
core.load_wsgi()

class TestLeselysAPI(unittest.TestCase):

    def setUp(self):
        self.r = core.app.test_client()

    def test_01_home(self):
        with self.r as c:
            rv = c.get('/?jsonsify=true')
            print(rv.status_code)
            print(rv.data)

if __name__ == "__main__":
    unittest.main()