def test_apiGetAuthToken(init): user = User.query.filter_by(nickname='utest').first() # Assert answer is auth token r = app.test_client().get(url_for('apiGetAuthToken'), follow_redirects=True ) r = app.test_client().post(url_for('apiGetAuthToken'), headers={ 'Authorization': 'Basic %s' % base64.b64encode(b'[email protected]:pptest').decode('utf-8') }) data = r.get_data() assert r.status_code == 200 result = json.loads(data.decode('utf-8')) assert result['authToken'] == 'ddg56@dgfdG°dkjvk,' assert result['nickname'] == 'utest' # Assert not authentified r = app.test_client().post(url_for('apiGetAuthToken'), follow_redirects=True ) r = app.test_client().post(url_for('apiGetAuthToken'), headers={ 'Authorization': 'Basic %s' % base64.b64encode(b'[email protected]:ppteste').decode('utf-8') }) data = r.get_data() assert r.status_code == 401 assert b'<h1>Unauthorized</h1>' in data
def test_error_config_blueprint(self): views = LazyViews(blueprint, import_prefix='weird.path') views.add('/more-advanced', 'views.advanced', endpoint='more_advanced') app.blueprints.pop('test') app.register_blueprint(blueprint, url_prefix='/test') self.assertIn('test.more_advanced', app.view_functions) test_app = app.test_client() self.assertRaises(ImportStringError, test_app.get, self.url('test.more_advanced')) views = LazyViews(blueprint, blueprint.import_name) views.add('/more-more-advanced', 'views.does_not_exist', endpoint='more_more_advanced') app.blueprints.pop('test') app.register_blueprint(blueprint, url_prefix='/test') self.assertIn('test.more_more_advanced', app.view_functions) test_app = app.test_client() self.assertRaises(ImportStringError, test_app.get, self.url('test.more_more_advanced'))
def test_create_page(): with app.test_client() as c: with c.session_transaction() as s: s.clear() rv = http(c, "post", "/pages", dict(notebook_id=notebook_id, index=1)) assert rv.status_code == 401 assert "You have to login first." in rv.data with app.test_client() as c: with c.session_transaction() as s: s["is_login"] = True s["id"] = 1 rv = http(c, "post", "/pages", dict(notebook_id=notebook_id, index=1)) assert rv.status_code == 404 assert "Notebook is not found." in rv.data with app.test_client() as c: with c.session_transaction() as s: s["is_login"] = True s["id"] = user_id previous_count = len(session.query(Page).filter_by(notebook_id=notebook_id).all()) rv = http(c, "post", "/pages", dict(notebook_id=notebook_id, index=1)) current_count = len(session.query(Page).filter_by(notebook_id=notebook_id).all()) assert rv.status_code == 201 assert "id" in rv.data assert "index" in rv.data assert current_count == previous_count + 1
def test_error_config_app(self): views = LazyViews(app, 'weird.path') views.add('/default-page', 'views.page', defaults={'page_id': 1}, endpoint='default_page') self.assertIn('default_page', app.view_functions) test_app = app.test_client() self.assertRaises(ImportStringError, test_app.get, self.url('default_page')) views = LazyViews(app, 'testapp.views') views.add('/another-default-page', 'does_not_exist', endpoint='another_default_page') self.assertIn('another_default_page', app.view_functions) test_app = app.test_client() self.assertRaises(ImportStringError, test_app.get, self.url('another_default_page'))
def test_histogram(self): with app.test_client() as c: resp = c.get('/histogram/network') self.assertEqual(resp.status_code, 200) with app.test_client() as c: resp = c.get('/histogram/fail') self.assertEqual(resp.status_code, 404)
def test_edit_allergen(self): # Test Edit Allergen page, that it loads the specific information about said allergen to be edited. tester = app.test_client(self) tester = app.test_client(self) response = tester.get('/edit_allergen/{}'.format(2), content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b"Edit Allergen" in response.data) self.assertTrue(b"Wheat (such as spelt and Khorasan wheat/Kamut)" in response.data)
def test_email_is_available(): with app.test_client() as c: rv = http(c, "get", "/users/check_email_availability/[email protected]") assert rv.status_code == 409 assert "Email has been used." in rv.data with app.test_client() as c: rv = http(c, "get", "/users/check_email_availability/[email protected]") assert rv.status_code == 200 assert "OK." in rv.data
def test_username_is_available(): with app.test_client() as c: rv = http(c, "get", "/users/check_username_availability/livoras") assert rv.status_code == 409 assert "Username has been used." in rv.data with app.test_client() as c: rv = http(c, "get", "/users/check_username_availability/fuckyoulucy") assert rv.status_code == 200 assert "OK." in rv.data
def setUp(self): print '--- db setup ---' db.create_all() app.config['TESTING'] = True self.app = app.test_client() self.app2 = app.test_client() self.app_token = None print ''
def test_map(self): with app.test_client() as c: resp = c.get('/map') self.assertEqual(resp.status_code, 200) with app.test_client() as c: resp = c.get('/map/AAA') self.assertEqual(resp.status_code, 404) with app.test_client() as c: resp = c.get('/map/AAA/BBB') self.assertEqual(resp.status_code, 200)
def setUp(self): app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///'+\ os.path.join(basedir, TEST_DB) self.app = app.test_client() db.create_all()
def setUpClass(self): call("psql -U postgres -d wopr_test -c \"create extension postgis;\"", shell=True) call("psql -U postgres -d wopr_test -c 'grant all on geometry_columns to \"wopr\";'", shell=True) call("psql -U postgres -d wopr_test -c \'grant all on spatial_ref_sys to \"wopr\";\'", shell=True) self.engine = create_engine(CONN) Base.metadata.create_all(self.engine) Session = sessionmaker(bind=self.engine) self.session = Session() for row in make_rows('test_fixtures/master.csv'): self.session.add(Master(**row)) for row in make_rows('test_fixtures/crime.csv'): self.session.add(Crime(**row)) for row in make_rows('test_fixtures/business.csv'): self.session.add(BusinessLicense(**row)) self.session.commit() self.app = app.test_client() self.maxDiff = None self.geo = { "type":"Feature", "properties":{}, "geometry":{ "type":"Polygon", "coordinates":[ [[-87.67913818359375,41.850843709419685], [-87.67913818359375,41.88050217228977], [-87.62969970703125,41.88050217228977], [-87.62969970703125,41.850843709419685], [-87.67913818359375,41.850843709419685]] ] } }
def test_single(self): """ Single layer results in a single NamedLayer """ with app.test_client() as c: c.get("/") sld = render_sld(["habitats"], {}) assert "habitats" in sld assert sld.count('<NamedLayer>') == 1
def setup(self): app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db') self.app = app.test_client() db.create_all() def teardown(self): db.session.remove() db.drop_all() def test_avatar(self): user = User(nickname='john', email='*****@*****.**') avatar = user.avatar(128) expected = 'http://www.gravatar.com/avatar/d4c74594d841139328695756648b6bd6' assert avatar[0:len(expected)] == expected def test_make_unique_nickname(self): user = User(nickname='john', email='*****@*****.**') db.session.add(user) db.session.commit() nickname = User.make_unique_nickname('john') assert nickname != 'john' u = User(nickname = nickname, email='*****@*****.**') db.session.add(u) db.session.commit() nickname2 = User.make_unique_nickname('john') assert nickname2 != 'john' assert nickname2 != nickname
def test_logout_redirect(self): self.initialize_test_user() tester = app.test_client(self) response = tester.post( '/auth/signout/', content_type='html/text', follow_redirects=True)
def setUp(self): db.session.close() db.drop_all() db.create_all() self.app = app.test_client() if not os.path.exists('users/'): os.makedirs('users/')
def setUp(self): app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + \ os.path.join(basedir, 'test.db') self.app = app.test_client() db.create_all()
def test_change_password_recover(self): self.initialize_test_user() tester = app.test_client(self) usertest = User.query.filter(User.username == 'Testuser').first() token = usertest.generate_token() old_password = usertest.password # test initialization of form Change Password url = '/auth/change_pass/?token='+str(token) response = tester.get( url, content_type='html/text,', follow_redirects=True ) self.assertEqual(response.status_code, 200) self.assertIn(b'Change Password', response.data) # Test functionality of Change Password data = { 'password': '******', 'confirm': 'new_test' } response_post = tester.post( url, data=data ) self.assertIn(b'password updated successfully', response_post.data) self.assertIsNot(usertest.password, old_password)
def test_logout(self): tester = app.test_client(self) tester.post('/login', data=dict(username='******', password='******'), follow_redirects=True) response = tester.get('/logout', follow_redirects=True) self.assertIn(b'You just logged out!', response.data)
def setUp(self): self.app = app.test_client() self.app_context = app.app_context() self.app_context.push() db.drop_all() db.create_all() self.admin_role = self._create_admin_role()
def setUp(self): if os.environ.get('FLASK_SEED_SETTINGS'): os.environ['FLASK_SEED_SETTINGS'] = '' import default_settings default_settings.TEMPLATE_DEBUG = True from app import app from flask.ext.mongoengine import MongoEngine from util import now app.config.from_object('default_settings') app.config['MONGODB_DB'] = 'flask_seed_unittest' app.config['DEBUG'] = True app.config['TESTING'] = True self.tests_data_yaml_dir = app.config['HOME_PATH'] + 'tests/data/yaml/' self.usecase = usecase.UseCase(self.tests_data_yaml_dir) app.db = MongoEngine(app) self._flush_db() self.config = app.config self.app = app.test_client() # self.flask_app = app self.g = globals.load() self.g['usr'] = {"OID": "50468de92558713d84b03fd7", "at": (-84.163063, 9.980516)} self.g['db'] = app.db self.used_keys = []
def test_word_verification(self): ''' Testing my trainer cases for accuracy ''' self.app = app.test_client() response = self.app.get('/markov/word/reicive', content_type='application/x-www-form-urlencoded') self.assertEquals(response.status_code, 200) self.assertTrue('"Word": false,' in response.data) #The bad words will have some cases of return true, I highly don't want to make a harder smoothing case; #However, I've documented the ones which I believe to be true. good_bad_words = 0 with open('trainer_text/bad.txt', "rb") as word_list: for line in word_list: check = line.strip().lower() response = self.app.get('/markov/word/' + check, content_type='application/x-www-form-urlencoded') if "false" in response.data: self.assertTrue('false' in response.data) else: good_bad_words += 1 self.assertEqual(good_bad_words, 14) with open('trainer_text/wordsEn.txt', "rb") as word_list: for line in word_list: check = line.strip().lower() response = self.app.get('/markov/word/' + check, content_type='application/x-www-form-urlencoded') print "checking " + check self.assertTrue('true' in response.data)
def setUp(self): app.config['TESTING'] = True app.debug = False app.config['WTF_CSRF_ENABLED'] = True self.baseURL = 'http://localhost:5000' self.client = app.test_client()
def setUp(self): self.old_REDIS_HOST = app.config['REDIS_HOST'] self.old_REDIS_PORT = app.config['REDIS_PORT'] self.old_REDIS_DB = app.config['REDIS_DB'] app.config['TESTING'] = True self.app = app.test_client()
def setUp(self): app.config['Testing'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + os.path.join(basedir, 'test_db.db') self.app = app.test_client() # create client test browser db.create_all()
def test_guest_page(): client = app.test_client() rsp = client.get('/report/guest/test') assert rsp.status == '200 OK' html = rsp.get_data(as_text=True) assert '<input class="form-control" id="name" name="name" placeholder="Your name" type="text" value="">' in html assert '<input class="form-control" id="reason" name="reason" placeholder="Specify a reason for unblocking this site" type="text" value="">' in html
def test_multi_company_detail(self): self.test_app = app.test_client() response = self.test_app.post('/', data={'From': '9149076903', 'Body':'GOOGL,detail,fb,amzn'}) self.assertEquals(response.status, "200 OK") # test_resource ={ # "resource" : { # "classname" : "Quote", # "fields" : { # "change" : "11.839966", # "chg_percent" : "1.619495", # "day_high" : "743.809998", # "day_low" : "735.765015", # "issuer_name" : "Alphabet Inc.", # "issuer_name_lang" : "Alphabet Inc.", # "name" : "Alphabet Inc.", # "price" : "742.929993", # "symbol" : "GOOGL", # "ts" : "1465416000", # "type" : "equity", # "utctime" : "2016-06-08T20:00:00+0000", # "volume" : "1615712", # "year_high" : "810.350000", # "year_low" : "539.210000" # } # } # }
def setUp(self): self.app = app.test_client() self.app.testing = True #self.app = app.app.test_client() #turn back on if need be #self.app.config['TESTING'] = True #take out if you have to self.db_fd, app.config['DATABASE'] = tempfile.mkstemp() app.config['TESTING'] = True
def setUp(self): app.config['MONGODB_SETTINGS'] = { 'host': os.environ.get('MONGOLAB_URI') or 'mongodb://localhost/vocabulary', 'db': 'vocabulary' } app.config['TESTING'] = True self.app = app.test_client()
def setUp(self): import pdb; pdb.set_trace() app.config['TESTING'] = True app.config['CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/earthmd_db' self.app = app.test_client() db.create_all()
from nose.tools import * from app import app from tests.tools import assert_response client = app.test_client() client.testing = True def test_index(): global client resp = client.get('/') assert_response(resp, status=302) resp = client.get('/game') assert_response(resp) resp= client.post('/game') assrt_reponse(resp, contains="You Died!") # Go to another scene in the game testdata = {'userinput': 'tell a joke'} resp = client.post('/game', data=testdata) assert_response(resp, contains="Laser Weapon Armory") # From there, go to another scene testdata = {'userinput': '123'} resp = client.post(/'game', data=testdata) assrt_response(resp, contains="The Bridge")
def test_login_page_loads(self): tester = app.test_client(self) response = tester.get('/login', content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b'Please Log in' in response.data)
def test_incorrect_login(self): tester = app.test_client(self) response = tester.post('/login', data=dict(username="******", password="******"), follow_redirects=True) self.assertTrue(b'Field must be between 6' in response.data)
def setUp(self): # Cria uma instância do unittest, precisa do nome "setUp" self.app = app.test_client() # Envia uma requisição GET para a URL self.result = self.app.get('/')
def test_library_page_loads(self): tester = app.test_client(self) response = tester.get('/', content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b'Available Code Templates' in response.data)
def client(): app.testing = True return app.test_client()
def setUp(self): app.config['TESTING'] = True app.config['DEBUG'] = False self.app = app.test_client() self.assertEquals(app.debug, False)
def test_delete_post_redirect(self): """Delete a single post then redirect""" with app.test_client() as client: response = client.post(f"/delete_post/{self.post.id}") self.assertEqual(response.status_code, 302)
def test_add_request_page_loads(self): tester = app.test_client(self) response = tester.get('/add_request', content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b'Add Template' in response.data)
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db' self.app = app.test_client() db.create_all()
def setUp(self): self.app = app.test_client() self.db = db.get_db()
def setUp(self): app.config['TESTING'] = True self.app = app.test_client()
def setUp(self): self.app = app.test_client() self.app.testing = True
def setUp(self): self.app = app.test_client()
def testUser(self): #GET #bad id outcome = app.test_client().get('/users/bad_id') self.assertEqual(outcome.status_code, 404) #good one id = getId('Example') outcome = app.test_client().get('/users/' + str(id)) self.assertEqual(outcome.status_code, 200) self.assertEqual( json.loads(outcome.data)['userdata']['Name'], "Example") self.assertEqual( json.loads(outcome.data)['userdata']['E-Mail'], "*****@*****.**") self.assertEqual( json.loads(outcome.data)['userdata']['EloStandard'], 1200) #PUT #getting token needed for further tests outcome = app.test_client().post('/login', data={ 'name': 'Example', 'password': '******' }) token = json.loads(outcome.data)['access_token'] #good one outcome = app.test_client().put( '/users/' + str(id), headers={'Authorization': 'Bearer ' + token}, data={ 'name': 'Example2', 'password': '******' }) self.assertEqual(outcome.status_code, 201) self.assertEqual( json.loads(outcome.data)['userdata']['Name'], "Example2") #bad id outcome = app.test_client().put( '/users/bad_id', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 404) register('Example', 'Password', '*****@*****.**') id2 = getId('Example') #not an owner outcome = app.test_client().put( '/users/' + str(id2), headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 403) #name taken outcome = app.test_client().put( '/users/' + str(id), headers={'Authorization': 'Bearer ' + token}, data={'name': 'Example'}) self.assertEqual(outcome.status_code, 400) #unauthorized outcome = app.test_client().put('/users/' + str(id)) self.assertEqual(outcome.status_code, 401) #bad token outcome = app.test_client().put('/users/' + str(id), headers={'Authorization': 'Non-token'}) self.assertEqual(outcome.status_code, 401) #login attempt with old data outcome = app.test_client().post('/login', data={ 'name': 'Example2', 'password': '******' }) self.assertEqual(outcome.status_code, 400) #login with new data outcome = app.test_client().post('/login', data={ 'name': 'Example2', 'password': '******' }) self.assertEqual(outcome.status_code, 201) #DELETE #bad id outcome = app.test_client().delete( '/users/bad_id', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 404) #not an owner outcome = app.test_client().delete( '/users/' + str(id2), headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 403) #unauthorized outcome = app.test_client().delete('/users/' + str(id)) self.assertEqual(outcome.status_code, 401) #bad token outcome = app.test_client().delete( '/users/' + str(id), headers={'Authorization': 'Non-token'}) self.assertEqual(outcome.status_code, 401) #good one outcome = app.test_client().delete( '/users/' + str(id), headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 201)
def test_base_route(): client = app.test_client() url = '/' response = client.get(url) assert response.get_data() == b'Buenos D\xc3\xadas, ChikiMan <3!' assert response.status_code == 200
def test_hello_you(name): tester = app.test_client() response = tester.get(f"/powitanie/{name}") assert response.status_code == 200 assert response.get_data().decode() == f"Witam serdecznie, {name}"
def testOfferList(self): outcome = app.test_client().post('/login', data={ 'name': 'Example', 'password': '******' }) token = json.loads(outcome.data)['access_token'] #POST #good one outcome = app.test_client().post( '/offers', headers={'Authorization': 'Bearer ' + token}, data={ 'time': 900, 'color': 'badData' }) self.assertEqual(outcome.status_code, 201) offer = json.loads(outcome.data)['offer'] self.assertEqual(offer['time'], 900) self.assertEqual(offer['time_add'], None) self.assertEqual(offer['color'], 'random') self.assertEqual(offer['owner_name'], 'Example') self.assertEqual(offer['type'], 'standard') #unauthorized outcome = app.test_client().post('/offers', data={ 'time': 900, 'color': 'white' }) self.assertEqual(outcome.status_code, 401) #bad token outcome = app.test_client().post( '/offers', data={'time': 900}, headers={'Authorization': 'Non-token'}) self.assertEqual(outcome.status_code, 401) #GET #good ones (testing different query strings) outcome = app.test_client().get( '/offers', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 200) list = json.loads(outcome.data)['offerlist'] self.assertEqual(len(list), 2) outcome = app.test_client().get( '/offers?min_time=600', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 200) list = json.loads(outcome.data)['offerlist'] self.assertEqual(len(list), 1) self.assertEqual(list[0], offer) outcome = app.test_client().get( '/offers?min_time=300&max_time=900', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 200) list = json.loads(outcome.data)['offerlist'] self.assertEqual(len(list), 2) outcome = app.test_client().get( '/offers?max_time=120', headers={'Authorization': 'Bearer ' + token}) self.assertEqual(outcome.status_code, 200) list = json.loads(outcome.data)['offerlist'] self.assertEqual(list, []) #unauthorized outcome = app.test_client().get('/offers') self.assertEqual(outcome.status_code, 401) #bad token outcome = app.test_client().get('/offers', headers={'Authorization': 'Non-token'}) self.assertEqual(outcome.status_code, 401)
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
def test_home_powitanie(self): tester = app.test_client(self) # To samo co powyżej, ale dla endpointu "/powitanie" response = tester.get('/powitanie') self.assertEqual(response.status_code, 200) self.assertEqual(response.get_data(), b"Witam na moim API!")
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv("DATABASE_URL") self.app = app.test_client() db.create_all()
def setUp(self): app.config['TESTING'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://%s:%s@%s/%s' % (\ TEST_DB_CONFIG['username'],\ TEST_DB_CONFIG['password'],\ TEST_DB_CONFIG['server'],\ TEST_DB_CONFIG['db']) db.init_app(app) with app.app_context(): db.create_all() asset_a = Asset(model='Mac Book Pro', company='NCCC', asset_tag='a', asset_state='已报废', sn='sn1', user='******', location='sh', type='pc') asset_b = Asset(model='Mac Book Pro', company='NCCC', asset_tag='b', asset_state='已报废', sn='sn2', user='******', location='sh', type='laptop') asset_c = Asset(model='Mac Book Pro', company='NCCC', asset_tag='c', asset_state='已报废', sn='sn3', user='******', location='sh', type='laptop') asset_d = Asset(model='Mac Book Pro', company='NCCC', asset_tag='d', asset_state='', sn='sn4', user='******', location='bj', type='pc') asset_e = Asset(model='Mac Book Pro', company='NCCC', asset_tag='e', asset_state='在用', sn='sn5', user='******', location='bj', type='ipad') asset_f = Asset(model='Mac Book Pro', company='NCCC', asset_tag='f', asset_state='在用', sn='sn6', user='******', location='bj', type='ipad') db.session.add_all( [asset_a, asset_b, asset_c, asset_d, asset_e, asset_f]) db.session.commit() self.app = app.test_client()
def test_index(self): tester = app.test_client(self) response = tester.get('/cities.json', content_type='application/json') self.assertEqual(response.status_code, 200) #print(response.data.decode('unicode_escape')) self.assertEqual(response.data.decode('unicode_escape'), json.dumps(['Amsterdam', 'San Franci', 'Berlin', 'New York']))
def test_delete_missing_cupcake(self): with app.test_client() as client: url = f"/api/cupcakes/100" resp = client.delete(url) self.assertEqual(resp.status_code, 404)
def test_clustering_page_loads(self): tester = app.test_client(self) response = tester.get('/clustering', content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b'clustering' in response.data)
def setUp(self): """set up before every test""" self.client = app.test_client() app.config['TESTING'] = True
def test_login(self): tester = app.test_client(self) response = tester.get('/login', content_type='html/text') self.assertEqual(response.status_code, 200)
def test_logout_requires_login(self): tester = app.test_client(self) response = tester.get('/logout', follow_redirects=True) self.assertTrue(b'Please Log in' in response.data)
def setUp(self): # cria uma instância do unittest, precisa do nome "setUp" self.app = app.test_client()
def test_edit_code_page_loads(self): tester = app.test_client(self) response = tester.get('/edit_code/1', content_type='html/text') self.assertEqual(response.status_code, 200) self.assertTrue(b'Edit Template' in response.data)