1+ # import unittest
2+ # from app import app
3+
4+ # class FlaskAppTestCase(unittest.TestCase):
5+ # def setUp(self):
6+ # # Create a test client
7+ # self.app = app.test_client()
8+ # self.app.testing = True
9+
10+ # def test_home(self):
11+ # # Send a GET request to the home page
12+ # response = self.app.get('/')
13+
14+ # # Check if the status code is 200 (OK)
15+ # self.assertEqual(response.status_code, 200)
16+
17+ # # Check if the response data is as expected
18+ # self.assertEqual(response.json, {"message": "Hello level 400 FET, Quality Assurance!"})
19+
20+ # if __name__ == '__main__':
21+ # unittest.main()
22+
23+ # lecturers version
24+ # test_app.py
125import unittest
226from app import app
327
4- class FlaskAppTestCase (unittest .TestCase ):
28+
29+ class TestApp (unittest .TestCase ):
530 def setUp (self ):
6- # Create a test client
731 self .app = app .test_client ()
8- self .app .testing = True
932
10- def test_home (self ):
11- # Send a GET request to the home page
33+ def test_home_route (self ):
1234 response = self .app .get ('/' )
13-
14- # Check if the status code is 200 (OK)
1535 self .assertEqual (response .status_code , 200 )
16-
17- # Check if the response data is as expected
1836 self .assertEqual (response .json , {"message" : "Hello level 400 FET, Quality Assurance!" })
1937
38+
2039if __name__ == '__main__' :
2140 unittest .main ()
0 commit comments