コード例 #1
0
ファイル: main.py プロジェクト: djsilcock/flaskbb
def populate(bulk_data, test_data, posts, topics, force, initdb):
    """Creates the necessary tables and groups for FlaskBB."""
    if force:
        click.secho("[+] Recreating database...", fg="cyan")
        drop_database(db.engine.url)

        # do not initialize the db if -i is passed
        if not initdb:
            upgrade_database()

    if initdb:
        click.secho("[+] Initializing database...", fg="cyan")
        upgrade_database()

    if test_data:
        click.secho("[+] Adding some test data...", fg="cyan")
        create_test_data()

    if bulk_data:
        timer = time.time()
        topic_count, post_count = insert_bulk_data(int(topics), int(posts))
        elapsed = time.time() - timer
        click.secho("[+] It took {} seconds to create {} topics and {} posts"
                    .format(elapsed, topic_count, post_count), fg="cyan")

    # this just makes the most sense for the command name; use -i to
    # init the db as well
    if not test_data:
        click.secho("[+] Populating the database with some defaults...",
                    fg="cyan")
        create_default_groups()
        create_default_settings()
コード例 #2
0
def populate(bulk_data, test_data, posts, topics, force, initdb):
    """Creates the necessary tables and groups for FlaskBB."""
    if force:
        click.secho("[+] Recreating database...", fg="cyan")
        db.drop_all()

        # do not initialize the db if -i is passed
        if not initdb:
            create_latest_db()

    if initdb:
        click.secho("[+] Initializing database...", fg="cyan")
        create_latest_db()

    if test_data:
        click.secho("[+] Adding some test data...", fg="cyan")
        create_test_data()

    if bulk_data:
        timer = time.time()
        topic_count, post_count = insert_bulk_data(int(topics), int(posts))
        elapsed = time.time() - timer
        click.secho(
            "[+] It took {} seconds to create {} topics and {} posts".format(
                elapsed, topic_count, post_count),
            fg="cyan")

    # this just makes the most sense for the command name; use -i to
    # init the db as well
    if not test_data:
        click.secho("[+] Populating the database with some defaults...",
                    fg="cyan")
        create_default_groups()
        create_default_settings()
コード例 #3
0
ファイル: test_populate.py プロジェクト: eirnym/flaskbb
def test_insert_bulk_data(database):
    assert not insert_bulk_data(topic_count=1, post_count=1)

    create_test_data(categories=1, forums=1, topics=0)
    assert Topic.query.count() == 0

    topics, posts = insert_bulk_data(topic_count=1, post_count=1)
    assert Topic.query.count() == topics
    # -1 bc the topic post also counts as post
    assert Post.query.count() - 1 == posts
コード例 #4
0
def test_insert_bulk_data(database):
    assert not insert_bulk_data(topic_count=1, post_count=1)

    create_test_data(categories=1, forums=1, topics=0)
    assert Topic.query.count() == 0

    topics, posts = insert_bulk_data(topic_count=1, post_count=1)
    assert Topic.query.count() == topics
    # -1 bc the topic post also counts as post
    assert Post.query.count() - 1 == posts
コード例 #5
0
ファイル: manage.py プロジェクト: ulysseswolf/flaskbb
def createall():
    """
    Creates the database with some example content.
    """

    # Just for testing purposes
    db.drop_all()

    db.create_all()
    create_test_data()
コード例 #6
0
ファイル: manage.py プロジェクト: javaj0hn/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    To drop or create the databse use the '-d' or '-c' options.
    """
    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    print("Creating test data...")
    create_test_data()
コード例 #7
0
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    To drop or create the databse use the '-d' or '-c' options.
    """
    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    print("Creating test data...")
    create_test_data()
コード例 #8
0
ファイル: manage.py プロジェクト: delida/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if not dropdb:
        print("Dropping database...")
        db.drop_all()

    if not createdb:
        print("Creating database...")
        upgrade()

    app.logger.info("Creating test data...")
    create_test_data()
コード例 #9
0
ファイル: manage.py プロジェクト: xuemy/flaskbb
def createall(dropdb=False, createdb=False):
    """Creates the database with some testing content.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if not dropdb:
        app.logger.info("Dropping database...")
        db.drop_all()

    if not createdb:
        app.logger.info("Creating database...")
        db.create_all()

    app.logger.info("Creating test data...")
    create_test_data()
コード例 #10
0
ファイル: manage.py プロジェクト: vlttnv/flaskbb
def populate(dropdb=False, createdb=False):
    """Creates the database with some default data.
    If you do not want to drop or create the db add
    '-c' (to not create the db) and '-d' (to not drop the db)
    """

    if dropdb:
        print("Dropping database...")
        db.drop_all()

    if createdb:
        print("Creating database...")
        upgrade()

    app.logger.info("Creating test data...")
    create_test_data()
コード例 #11
0
ファイル: main.py プロジェクト: eirnym/flaskbb
def populate(bulk_data, test_data, posts, topics, force, initdb):
    """Creates the necessary tables and groups for FlaskBB."""
    if force:
        click.secho("[+] Recreating database...", fg="cyan")
        db.drop_all()

        # do not initialize the db if -i is passed
        if not initdb:
            create_latest_db()

    if initdb:
        click.secho("[+] Initializing database...", fg="cyan")
        create_latest_db()
        run_plugin_migrations()

    if test_data:
        click.secho("[+] Adding some test data...", fg="cyan")
        create_test_data()

    if bulk_data:
        click.secho("[+] Adding a lot of test data...", fg="cyan")
        timer = time.time()
        rv = insert_bulk_data(int(topics), int(posts))
        if not rv and not test_data:
            create_test_data()
            rv = insert_bulk_data(int(topics), int(posts))
        elapsed = time.time() - timer
        click.secho("[+] It took {:.2f} seconds to create {} topics and {} "
                    "posts.".format(elapsed, rv[0], rv[1]), fg="cyan")

    # this just makes the most sense for the command name; use -i to
    # init the db as well
    if not test_data and not bulk_data:
        click.secho("[+] Populating the database with some defaults...",
                    fg="cyan")
        create_default_groups()
        create_default_settings()
コード例 #12
0
ファイル: test_populate.py プロジェクト: eirnym/flaskbb
def test_create_test_data(database):
    assert Category.query.count() == 0
    data_created = create_test_data()
    assert Category.query.count() == data_created['categories']
コード例 #13
0
def test_create_test_data(database):
    assert Category.query.count() == 0
    data_created = create_test_data()
    assert Category.query.count() == data_created['categories']