def test_update_save_world(self): """ Test the save world data by updating the thankful members """ client = app.test_client() response = client.post( "/save/world/", data = json.dumps( dict( dtime = "2020-06-10 09:10:00", howsaved = "Saved from Tsunami", thanks_to_people = "Max\nThomas" ) ), content_type = 'application/json', ) assert response.status_code == 201 assert response.get_data().decode('utf-8') == 'Data saved' response = client.put( "/save/world/", data = json.dumps( dict( howsaved = "Saved from Tsunami", thanks_to_people = "Max\nThomas\Tom" ) ), content_type = 'application/json', ) assert response.status_code == 201 assert response.get_data().decode('utf-8') == '["Data updated"]\n'
def setUp(self): app = create_app('testing') # http://flask-sqlalchemy.pocoo.org/2.3/contexts/ self.context = app.app_context() self.context.push() db.create_all() self.runner = app.test_cli_runner() self.client = app.test_client()
def setUp(self): os.environ['WEBAPP_UNIT_TEST'] = '1' app.config['WTF_CSRF_ENABLED'] = False self.app = app.test_client() r = self.app.get('/reset_db') os.environ.pop('WEBAPP_UNIT_TEST') assert (r.status_code == 200) return
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUB'] = True self.app = app.test_client() self.app_context = app.app_context() self.app_context.push() db.create_all()
def test_create_save_world_data(self): """ Test creating save world data """ client = app.test_client() response = client.post( "/save/world/", data = json.dumps( dict( dtime = "2020-06-10 09:10:00", howsaved = "Saved from Tsunami", thanks_to_people = "Max\nThomas" ) ), content_type = 'application/json', ) assert response.status_code == 201 assert response.get_data().decode('utf-8') == 'Data saved'
def setUp(self): app.config['DEBUG'] = False app.config['TESTING'] = True self.app = app.test_client() self.modelwrapper = ModelWrap()
def setUp(self): self.app = app.test_client() app.app_context().push() user = User(email="*****@*****.**") db.session.add(user) db.session.flush()
def client(): testing_client = app.test_client() yield testing_client
def test_arizona(): response = app.test_client().get('/california') assert response.status_code == 200 assert response.data == b'Hello, California!'
def test_hello(): response = app.test_client().get('/') assert response.status_code == 200 assert response.data == b'Hello, World!'