コード例 #1
0
 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)
コード例 #2
0
 def test_pulling_from_database(self):
     tester = app.test_client(self)
     tester.post('/login',
                 data=dict(username="******", password="******"),
                 follow_redirects=True)
     count = 0
     pass
コード例 #3
0
    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)
コード例 #4
0
 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)
コード例 #5
0
 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)
コード例 #6
0
 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)
コード例 #7
0
 def test_flask_initiates(self):
     tester = app.test_client(self)
     response = tester.get('/login', content_type='html/text')
     self.assertEqual(response.status_code, 200)