def app_context(): """ A fixture for running the test inside an app context. """ from superset.app import create_app app = create_app() with app.app_context(): yield
def test_client(): app = create_app() with app.test_client() as client: with app.app_context() as app_context: # noqa admin = app.appbuilder.sm.find_role("Admin") app.appbuilder.sm.add_user( username="******", first_name="test", last_name="test", email="test", role=admin) yield client
from superset import app app1 = app.create_app()
results[f"{min_entities}+"] = duration min_entities *= 10 if auto_cleanup: print("Cleaning up DB") # delete in reverse order of creation to handle relationships for model, entities in list(new_models.items())[::-1]: session.query(model).filter( model.id.in_( entity.id for entity in entities)).delete(synchronize_session=False) session.commit() if current_revision != revision and not force: click.confirm(f"\nRevert DB to {revision}?", abort=True) upgrade(revision=revision) print("Reverted") print("\nResults:\n") for label, duration in results.items(): print(f"{label}: {duration:.2f} s") if __name__ == "__main__": from superset.app import create_app app = create_app() with app.app_context(): # pylint: disable=no-value-for-parameter main()