class HelloWorldTestCase(unittest.TestCase):
    testy = app.test_client()

    def test_index_status_code(self):
        response = self.testy.get('/')
        self.assertEqual(response.status_code, 200)

    def test_index_data(self):
        response = self.testy.get('/')
        raw = response.data
        result = raw.decode("utf-8")
        self.assertEqual(result, 'Hello, world!')

    def test_home_status_code(self):
        response = self.testy.get('/home')
        self.assertEqual(response.status_code, 200)

    def test_home_data(self):
        response = self.testy.get('/home')
        raw = response.data
        result = raw.decode("utf-8")
        self.assertEqual(result, 'Welcome to an amazing Flask App!')

    def test_myprofile_status_code(self):
        response = self.testy.get('/myprofile')
        self.assertEqual(response.status_code, 200)

    def test_myprofile_data(self):
        response = self.testy.get('/myprofile')
        raw = response.data
        result = raw.decode("utf-8")
        self.assertEqual(result,
                         'This is my profile! It\'s not finished yet... :/')

    def test_exit_status_code(self):
        response = self.testy.get('/exit')
        self.assertEqual(response.status_code, 200)

    def test_exit_data(self):
        response = self.testy.get('/exit')
        raw = response.data
        result = raw.decode("utf-8")
        self.assertEqual(result,
                         'Thanks for looking around. Come back again soon!')
コード例 #2
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
コード例 #3
0
ファイル: test_hello_world.py プロジェクト: aida72/TrgProject
 def setUp(self):
     app.testing = True
     app.config["SERVER_NAME"] = 'localhost:8087'
     self.app = app.test_client()
コード例 #4
0
def client():
    test_client = app.test_client()
    return test_client
コード例 #5
0
 def setUp(self):
     app.config['TESTING'] = True
     self.app = app.test_client()
コード例 #6
0
 def test_msg_output(self):
     self.app = app.test_client()
     r = self.app.get('/')
     self.assertTrue('Adrian Hello World!' in r.data)
コード例 #7
0
 def setUp(self):
     self.server = MockupDB(auto_ismaster=True, verbose=True)
     self.server.run()
     app.config['TESTING'] = True
     app.config['MONGO_URI'] = self.server.uri
     self.app = app.test_client()
コード例 #8
0
def test_hello():
    response = app.test_client().get('/')

    assert response.status_code == 200
    assert response.data == b'Hello World!'