def setUp(self): """Do at the beginning of every test""" # Get the Flask test client self.client = app.test_client() # Show Flask errors that happen during tests app.config['TESTING'] = True # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables from model db.create_all() # Import different types of data from seed file seed.load_users() seed.load_groups() seed.load_usergroups() seed.load_patterns() seed.load_invites() # Reset auto incrementing primary keys to start after seed data seed.set_val_user_id() seed.set_val_group_id() seed.set_val_usergroup_id() seed.set_val_pattern_id() seed.set_val_invite_id() with self.client as c: with c.session_transaction() as sess: sess['user_id'] = 1 c.set_cookie('localhost', 'MYCOOKIE', 'cookie_value')
def setUp(cls): """Do once before all tests in this class""" # Get the Flask test client cls.client = app.test_client() # Show Flask errors that happen during tests app.config['TESTING'] = True # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables from model db.create_all() # Import different types of data from seed file seed.load_users() seed.load_groups() seed.load_usergroups() seed.load_patterns() seed.load_invites() seed.set_val_user_id() seed.set_val_group_id() seed.set_val_usergroup_id() seed.set_val_pattern_id() seed.set_val_invite_id() with cls.client as c: with c.session_transaction() as sess: sess['user_id'] = 1 c.set_cookie('localhost', 'MYCOOKIE', 'cookie_value')
def setUp(self): # Get the Flask test client self.client = app.test_client() # Show Flask errors that happen during tests app.config['TESTING'] = True # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables from model db.create_all() # Import different types of data from seed file seed.load_users() seed.load_groups() seed.load_usergroups() seed.load_patterns() seed.load_invites() # Reset auto incrementing primary keys to start after seed data seed.set_val_user_id() seed.set_val_group_id() seed.set_val_usergroup_id() seed.set_val_pattern_id() seed.set_val_invite_id()
def setUp(self): print "\n\n\n\n (2) DOING A SEARCH TEST \n\n\n\n" self.client = app.test_client() app.config['TESTING'] = True postgrespassword = os.environ['POSTGRES_PASSWORD'] db_uri = 'postgresql://' + postgrespassword + '/test' connect_to_db(app, db_uri) db.create_all() load_regions() load_users() load_bestuses() load_categories() load_brands() load_products() load_tents() load_filltypes() load_gendertypes() load_sleepingbags() load_padtypes() load_sleepingpads() load_ratings() load_histories() load_test_postalcodes()
def setUp(self): """Stuff to do before every test.""" # Get the Flask test client self.client = app.test_client() # Show Flask errors that happen during tests app.config['TESTING'] = True app.config['SECRET_KEY'] = 'key' with self.client as c: with c.session_transaction() as sess: sess['user_id'] = 1 # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables and add sample data db.create_all() load_users() def _mock_get_weather(): server.get_weather = _mock_get_weather return "Weather"
def setUp(self): print "(setUp ran)" self.client = server.app.test_client() server.app.config['TESTING'] = True connect_to_db(server.app, 'postgresql:///testdb') db.create_all() load_users() load_listings() load_numbers()
def setUp(self): self.client = app.test_client() app.config['TESTING'] = True connect_to_db(app, 'postgresql:///testdb') db.create_all() load_users() load_birds()
def setUp(self): """Prepare for each test before execution.""" connect_to_db(app, 'postgresql:///testdb') db.create_all() load_users() load_activities() load_sessions() load_records()
def setUp(self): self.client = app.test_client() app.config["TESTING"] = True app.config["SECRET_KEY"] = "key" connect_to_db(app, db_uri="postgresql:///testdb") db.create_all() load_users(username="******", password="******")
def setUp(self): """Stuff to do before every test.""" self.client = app.test_client() app.config['TESTING'] = True # Connect to test database (uncomment when testing database) connect_to_db(app, "postgresql:///testdb") # Create tables and add sample data (uncomment when testing database) db.create_all() load_users()
def setUp(self): self.db_fd, self.db_filename = tempfile.mkstemp() app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + self.db_filename app.config['TESTING'] = True app.testing = True app.config['WTF_CSRF_ENABLED'] = False self.test_client = app.test_client() db.app = app db.init_app(app) with app.app_context(): db.create_all() seed.load_users() seed.load_houses()
def setUp(self): self.db_fd, self.db_filename = tempfile.mkstemp() app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////" + self.db_filename app.config["TESTING"] = True app.testing = True app.config["WTF_CSRF_ENABLED"] = False self.test_client = app.test_client() db.app = app db.init_app(app) with app.app_context(): db.create_all() seed.load_users() seed.load_listings() seed.load_messages()
def setUp(self): #pragma no cover """set up test with db, and users""" #set up testing configurations app.config['TESTING'] = True app.config['SECRET_KEY'] = 'key' self.client = app.test_client() #connect to db connect_to_db(app, 'postgres:///testdb') db.create_all() #add a user to db load_users(1)
def setUp(self): """Runs before each test, gives testdb with fake_data""" # Connect to test database (must have 'createdb testdb' already!) connect_to_db(app, "postgresql:///testdb") # Create tables and add fake_data db.create_all() user_file = "fake_data/u.fake_users" loc_file = "fake_data/u.fake_locations" food_file = "fake_data/u.fake_foods" load_users(user_file) load_locations(loc_file) load_items(food_file)
def setUp(self): """Prepare for each test before execution.""" self.app = app.test_client() app.config['TESTING'] = True app.config['SECRET_KEY'] = 'key' connect_to_db(app, 'postgresql:///testdb') db.create_all() load_users() load_activities() load_sessions() load_records()
def setUp(self): """Stuff to do before every test.""" self.client = app.test_client() app.config['TESTING'] = True app.config['SECRET KEY'] = 'key' connect_to_db(app, "postgresql:///testdb") with self.client as c: with c.session_transaction() as sess: sess['user_id'] = 1 db.create_all() load_users()
def create_testdb(): connect_to_db(app, "postgresql:///testdb") db.create_all() # Import different types of data seed.delete_everything() seed.load_users() seed.load_tasks() seed.load_kaos() seed.load_collects() seed.load_used_kaos() seed.set_val_user_id() seed.set_val_task_id() seed.set_val_collect_id() seed.set_val_kao_id()
def setUp(self): """Stuff to do before every test.""" app.config["TESTING"] = True app.config["SECRET_KEY"] = "SECRET" self.client = app.test_client() # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables and add sample data db.create_all() load_users() db.session.commit() with self.client as c: with c.session_transaction() as sess: sess["user_id"] = 1
def setUp(self): """Stuff to do before every test.""" # Get the Flask test client self.client = app.test_client() # Show Flask errors that happen during tests app.config["TESTING"] = True # Connect to test database connect_to_db(app, "postgresql:///testdb") # Create tables and add sample data db.create_all() load_users() load_addresses() load_user_addresses() db.session.commit()
def connect_to_db(app): """Connect the database to our Flask app.""" # Configure to use our PostgreSQL database uri = 'postgresql://postgres@db/sugarcoins' app.config['SQLALCHEMY_DATABASE_URI'] = uri app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.app = app engine = create_engine(uri) seed = False if not database_exists(engine.url): create_database(engine.url) seed = True db.init_app(app) # automatically seed the database if we just created it if seed: db.create_all() if app.debug: # import cycle from seed import ( load_gender, load_users, load_food, load_sugar_intake, load_weight, load_weight_two, load_weight_three, load_glucose, load_glucose_two, load_glucose_three, ) load_gender() # here we loaded Gender first load_users() load_food() load_sugar_intake() load_weight() load_weight_two() load_weight_three() load_glucose() load_glucose_two() load_glucose_three()
def setUp(self): self.client = app.test_client() app.config['TESTING'] = True connect_to_db(app, "sqlite:////tmp/temp.db") db.create_all() load_regions() load_users() load_bestuses() load_categories() load_brands() load_products() load_tents() load_filltypes() load_gendertypes() load_sleepingbags() load_padtypes() load_sleepingpads() load_ratings() load_histories()
def setUp(self): """Runs before each test, gives fake server and testdb with fake_data""" # Creates fake server client that can make requests self.client = app.test_client() # This config will print all Flask errors to the console app.config['TESTING'] = True # To use session info, need secret key app.config['SECRET_KEY'] = 'wowsuchsecret' # Fake a user_id in the session so we can get access to pages where this is required with self.client.session_transaction() as sess: sess['user_id'] = 1 # Connect to test database (must have 'createdb testdb' already!) connect_to_db(app, "postgresql:///testdb") # Create tables and add fake_data db.create_all() user_file = "fake_data/u.fake_users" loc_file = "fake_data/u.fake_locations" food_file = "fake_data/u.fake_foods" load_users(user_file) load_locations(loc_file) load_items(food_file)