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
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
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()
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()
def insertbulkdata(topics, posts): """Warning: This can take a long time!. Creates 100 topics and each topic contains 100 posts. """ timer = time.time() created_topics, created_posts = insert_bulk_data(int(topics), int(posts)) elapsed = time.time() - timer print("It took {time} seconds to create {topics} topics and " "{posts} posts" .format(time=elapsed, topics=created_topics, posts=created_posts))
def insertbulkdata(topics, posts): """Warning: This can take a long time!. Creates 100 topics and each topic contains 100 posts. """ timer = time.time() created_topics, created_posts = insert_bulk_data(int(topics), int(posts)) elapsed = time.time() - timer print("It took {time} seconds to create {topics} topics and " "{posts} posts" .format(time=elapsed, topics=created_topics, posts=created_posts))
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()