Exemplo n.º 1
0
    def setUpClass(cls):
        print ""
        print cls.__display__

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        cls.app_key = 'testing'
        cls.api_token_admin = 'adminadmin'
        cls.api_token_member = 'membermember'
        cls.api_token_client = 'clientclient'

        drop_all()
        create_all()

        db.engine.execute('INSERT INTO `applications` (id, name, display, app_key, status) VALUES (1, "reflectiv", "Reflectiv", "testing", "DEV");')
        db.engine.execute('INSERT INTO `application_plans` (id, display, description, application_id, sms, members, storage, projects, monthly_price, yearly_price, currency, share) VALUES (1, "Free membership", "Free membership", 1, 0, 3, 0, 3, 0, 0, "USD", 50);')

        db.engine.execute('INSERT INTO `organizations` (name, display, currency, application_id, application_plan_id, created) VALUES ("reflectiv", "Reflectiv", "USD", 1, 1, "2014-04-01 00:00:00");')

        db.engine.execute('INSERT INTO `members` (id, display, organization_id, status, is_admin, is_disabled, lang) VALUES (1, "Administrator", 1, "MEMBER", 1, 0, "en"), (2, "Simple Member", 1, "MEMBER", 0, 0, "en"), (3, "Client", 1, "CLIENT", 0, 0, "en");')

        db.engine.execute('INSERT INTO `sessions` (expires, token, member_id) VALUES ("2015-12-31 00:00:00", "adminadmin", 1), ("2015-12-31 00:00:00", "membermember", 2), ("2015-12-31 00:00:00", "clientclient", 3);')
Exemplo n.º 2
0
    def run(self):
        try:
            from database import create_all

            create_all()
        except ImportError:
            print("Please, make sure database.create_all exists in order to create a db.")
Exemplo n.º 3
0
    def run(self):
        try:
            from database import create_all

            create_all()
        except ImportError:
            print("Please, make sure database.create_all exists in order to create a db.")
Exemplo n.º 4
0
    def setUp(self):
        import config
        from main import app_factory
        from database import create_all

        self.app = app_factory(config.Testing)
        self.client = self.app.test_client()
        create_all()
Exemplo n.º 5
0
def db():
    """
    Initializes and returns a SQLAlchemy DB object
    """
    the_db.session.close()
    the_db.drop_all()
    the_db.create_all()
    return the_db
Exemplo n.º 6
0
    def setUp(self):
        import config
        from main import app_factory
        from database import create_all

        self.app = app_factory(config.Testing)
        self.client = self.app.test_client()
        create_all()
Exemplo n.º 7
0
def db(request):
    # create tables in testing database
    create_all()

    def teardown():
        # drop tables after finishing test cases
        drop_all()

    request.addfinalizer(teardown)
Exemplo n.º 8
0
    def setUpClass(cls):
        print ""
        print cls.__display__

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        drop_all()
        create_all()
Exemplo n.º 9
0
def main():

    create_all()

    tornado.options.define("port", default=8002, help="run on the given port", type=int)
    tornado.options.options.logging = "debug"

    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(tornado.options.options.port)
    logging.debug("start locale web server 8002 ...")
    tornado.ioloop.IOLoop.current().start()
Exemplo n.º 10
0
    def setUpClass(cls):
        print("")
        print(cls.__display__)

        from main import app_factory
        from database import db, create_all, drop_all

        cls.app = app_factory(config.Testing)
        cls.client = cls.app.test_client()

        drop_all()
        create_all()

        db.engine.execute('INSERT INTO ...')  # Maybe some default datas ?
Exemplo n.º 11
0
def main():
    global options
    parser = OptionParser()
    parser.set_defaults(
            dbname = Config.Database.dbname,
            dbuser = Config.Database.dbuser,
            dbpasswd = Config.Database.dbpasswd,
            dbhost = Config.Database.dbhost,
            dbport = Config.Database.dbport,
            createtables = Config.Database.createtables
            )
            
    parser.add_option("--dbname", dest="dbname",
                      help="PostgreSQL database to connect the Llampex Engine", metavar="DBNAME")
    parser.add_option("--host", dest="dbhost",
                      help="PostgreSQL host to connect", metavar="DBHOST")
    parser.add_option("--port", dest="dbport", type="int",
                      help="PostgreSQL port to connect", metavar="DBPORT")
    parser.add_option("--user", dest="dbuser",
                      help="PostgreSQL User", metavar="DBUSER")
    parser.add_option("--pass", dest="dbpasswd",
                      help="PostgreSQL Password for User", metavar="DBUSER")
    parser.add_option("--createtables", dest="createtables", action="store_true",
                      help="Creates the needed tables if aren't in the database yet")
    parser.add_option("-q", "--quiet",
                      action="store_false", dest="verbose", default=True,
                      help="don't print status messages to stdout")                      

    (options, args) = parser.parse_args()
    dboptions = {}
    for key in dir(options):
        if key.startswith("db"):
            dboptions[key] = getattr(options,key)
    connect(dboptions,options.verbose)
    if options.createtables:
        create_all()
        
    engine.start(options.verbose)
    engine.wait()
Exemplo n.º 12
0
def init_db(): # type: ignore
    db.create_all()
    create_debugproxy_organization("debugproxy")
Exemplo n.º 13
0
    def run(self):
        from database import create_all

        create_all()
Exemplo n.º 14
0
 def run(self):
     create_all()
Exemplo n.º 15
0
 def run(self):
     drop_all()
     create_all()
     seed_all()
Exemplo n.º 16
0
 def run(self):
     drop_all()
     create_all()
     seed_all()
Exemplo n.º 17
0
from models import historicplace
"""

#import models.thing, models.offer#, models.request, models.comment
#import models.action, models.imageobject, models.openinghours
#import models.service, models.products
#import models.restaurant
#import models.person
#import models.events
# also model for system users and listing ownership

if __name__ == '__main__':
    application = app.create_app(config)

    database.init(application)
    database.create_all()

    if len(sys.argv) > 1 and sys.argv[1] == "--fixtures":
        # XXX support ,-delimited list of fixtures
        arg = sys.argv[2]

        import importlib
        try:
            m = importlib.import_module('fixtures.create_%s' % arg)
            m.insert_data(db)
        except Exception as e:
            import traceback
            traceback.print_exc()

    elif len(sys.argv) > 1 and sys.argv[1] == "--testfixture":
        arg = sys.argv[2]
Exemplo n.º 18
0
def create_tables():
    create_all()
Exemplo n.º 19
0
def init_db():
    print('## Init database ##')
    db.connect()
    db.create_all()
    print('Done')
Exemplo n.º 20
0
    def run(self):
        from database import create_all

        create_all()
Exemplo n.º 21
0
from database import create_all
from component.myForm import MyForm

if __name__ == '__main__':
    create_all()
    root = MyForm()
    root.mainloop()
Exemplo n.º 22
0
 def run(self):
     create_all()