Ejemplo n.º 1
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 2
0
 def tearDown(self):
     db.drop_all()
Ejemplo n.º 3
0
 def tearDown(self):
     """Tear Down."""
     db.session.remove()
     db.drop_all()
Ejemplo n.º 4
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
Ejemplo n.º 5
0
 def tearDown(self):
     db.drop_all()
Ejemplo n.º 6
0
def dropall():
    if prompt_bool("Are you sure ? You will lose all your data !"):
        db.drop_all()
Ejemplo n.º 7
0
def init_database():
    # create the database tables
    with app.app_context():
        db.create_all()

        # insert sample data
        source = CedSource(
            id="datacite", display_name="DataCite", icon_url="datacite.png"
        )
        event1 = CedEvent(
            id="peeZ2knsGxRzvuw4NVW6",
            doi="10.1039/c5ce01901j",
            api_raw=dict(
                {
                    "id": "80c78ffb-8d32-4de7-8023-1187dffdaef2",
                    "terms": "https://doi.org/10.13003/CED-terms-of-use",
                    "obj_id": "https://doi.org/10.1039/c5ce01901j",
                    "license": "https://creativecommons.org/publicdomain/zero/1.0/",
                    "subj_id": "https://doi.org/10.5517/cc13t0gd",
                    "source_id": "datacite",
                    "timestamp": "2017-06-28T04:23:34Z",
                    "occurred_at": "2014-12-01T14:09:33Z",
                    "source_token": "28276d12-b320-41ba-9272-bb0adc3466ff",
                    "message_action": "create",
                    "relation_type_id": "is_supplement_to",
                }
            ),
            occurred_at=datetime.strptime("2014-12-01", "%Y-%m-%d"),
            normalized_subj_id="https://doi.org/10.5517/cc13t0gd",
            uniqueness_key="08d64da78ed5223c2329d00350727581",
        )
        event2 = CedEvent(
            id="XnXvJVPNq2FkWD4VD6uv",
            doi="10.1039/c5ce01901j",
            api_raw=dict(
                {
                    "id": "4d6a48be-6d51-4d4b-be91-4d5929fa0ba0",
                    "terms": "https://doi.org/10.13003/CED-terms-of-use",
                    "obj_id": "https://doi.org/10.1039/c5ce01901j",
                    "license": "https://creativecommons.org/publicdomain/zero/1.0/",
                    "subj_id": "https://doi.org/10.5517/cc13t0hf",
                    "source_id": "datacite",
                    "timestamp": "2017-06-28T04:23:34Z",
                    "occurred_at": "2014-12-01T14:09:34Z",
                    "source_token": "28276d12-b320-41ba-9272-bb0adc3466ff",
                    "message_action": "create",
                    "relation_type_id": "is_supplement_to",
                }
            ),
            occurred_at=datetime.strptime("2014-12-01", "%Y-%m-%d"),
            normalized_subj_id="https://doi.org/10.5517/cc13t0hf",
            uniqueness_key="2ed6a1381d65683ec3c1ddf575d7709a",
        )
        db.session.add(source)
        db.session.add(event1)
        db.session.add(event2)

        # Commit the changes
        db.session.commit()

        yield db

        # remove tables
        db.session.remove()
        db.drop_all()
Ejemplo n.º 8
0
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys
from views import app, db, User, Config

application = app

if len(sys.argv) >= 2:
    # 获取命令行命令
    command = sys.argv[1]

    if command.lower() == 'imgrate':
        db.drop_all()
        db.create_all()
        admin = User(username='******', password='******')
        admin.save()
        cfg = Config(parameter='setting', value='OK')
        cfg.save()
        print('''
  The database has been initialized, the default username is 'admin', and the password is '123456'.
''')

    elif command.lower() == 'serve':
        if len(sys.argv) == 3:
            application.run('localhost', int(sys.argv[2]))
        elif len(sys.argv) == 4:
            application.run(sys.argv[2], int(sys.argv[3]))
        else:
            application.run('localhost', 5000)
    else:
 def tearDown(self):
     """
         Executing after to each tasks.
         Clean environnement.
     """
     db.drop_all()