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'New User?', response.data)
def test_pulling_from_database(self): tester = app.test_client(self) tester.post('/login', data=dict(username="******", password="******"), follow_redirects=True) count = 0 pass
def test_create_new(self): tester = app.test_client(self) tester.post('/login', data=dict(username="******", password="******"), follow_redirects=True) #tester.post('/addnew', data ={'title': "I HATE THIS"} , follow_redirects=True) # x = 1 # y = 2 # # tester.post('/_addContact', data = {'first_name': '{}'.format(x), # 'last_name': '{}'.format(x), # 'phone_num': '{}{}{}{}{}{}{}{}{}{}'.format(x,x,x,x,x,x,x,x,x,y), # 'address': '{}'.format(x), # 'city': '{}'.format(x), # 'state': '{}'.format(x), # 'zipcode':'{}{}{}{}{}'.format(x,x,x,x,y), # 'id':'{}'.format(x+y)} # ) # tester.post('/_addContact', follow_redirects=True) # tester.post('/addnew/save', data= dict(book_name="Backend testing"), follow_redirects=True) tester.post('/openExisting/backendtesting', follow_redirects=True) for y in range(2): for x in range(10): tester.post('/_addContact', data={ 'first_name': '{}'.format(x), 'last_name': '{}'.format(x), 'phone_num': '{}{}{}{}{}{}{}{}{}{}'.format( x, x, x, x, x, x, x, x, x, y), 'address': '{}'.format(x), 'city': '{}'.format(x), 'state': '{}'.format(x), 'zipcode': '{}{}{}{}{}'.format(x, x, x, x, y), 'id': '{}'.format(x + y) }) tester.post('/_addContact', follow_redirects=True) #print("RUNNING") tester.post('/addnew/save', data=dict(book_name="Backend testing"), follow_redirects=True)
def test_main_page_requires_login(self): tester = app.test_client(self) response = tester.get('/', follow_redirects=True) self.assertTrue(b'Please log in to access this page.' in response.data)
def test_login_correct(self): tester = app.test_client(self) response = tester.post('/login', data=dict(username="******", password="******"), follow_redirects=True) self.assertIn(b'Create Your Own Address Book', response.data)
def test_login_incorrect(self): tester = app.test_client(self) response = tester.post('/login', data=dict(username="******", password="******"), follow_redirects=True) self.assertIn(b'Invalid username or password', response.data)
def test_flask_initiates(self): tester = app.test_client(self) response = tester.get('/login', content_type='html/text') self.assertEqual(response.status_code, 200)