def setUp(self): self.app = app self.ctx = self.app.app_context() self.ctx.push() db.drop_all() db.create_all() # Creating the 1st user. This user will issue a request user = User(username=self.default_username) user.set_password_hash(self.default_password) db.session.add(user) db.session.commit() self.client = TestClient(self.app, user.generate_auth_token(), '') # Create a request for 1st user request_data = { 'meal_type': 'Vietnamese', 'meal_time': 'Dinner', 'location_string': 'San Francisco' } rv, json = self.client.post(API_VERSION + '/requests/', data=request_data) self.request_location = rv.headers['Location'] # Create the 2nd user. This user will make proposal for the request by # 1st user user_2 = User(username='******') user_2.set_password_hash('123456') db.session.add(user_2) db.session.commit() self.client = TestClient(self.app, user_2.generate_auth_token(), '')
def setUp(self): self.app = app self.ctx = self.app.app_context() self.ctx.push() db.drop_all() db.create_all() user = User(username=self.default_username) user.set_password_hash(self.default_password) db.session.add(user) db.session.commit() self.client = TestClient(self.app, user.generate_auth_token(), '')
def client(): test_client = app.test_client() db.drop_all() db.create_all() user = User(username='******') user.set_password_hash('123456') db.session.add(user) db.session.commit() yield test_client """ tearDown code """ db.session.remove() db.drop_all()
def add_user(username, password): user = User(username=username) user.set_password_hash(password) db.session.add(user) db.session.commit() print "Added {0}!".format(user.username)