نسخ من Omar-268/flask_app
adding testing
هذا الالتزام موجود في:
26
test_app.py
26
test_app.py
@@ -1,8 +1,20 @@
|
||||
from app import app
|
||||
"""Unit tests for the Flask application."""
|
||||
|
||||
def test_homepage():
|
||||
|
||||
with app.test_client() as client:
|
||||
response = client.get('/')
|
||||
assert response.status_code == 200
|
||||
assert b"Hello, Worlddddddddddd!!!" in response.data
|
||||
import unittest
|
||||
from flask_app.app import app
|
||||
|
||||
class FlaskAppTestCase(unittest.TestCase):
|
||||
"""Test cases for the Flask application."""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up the test client before each test."""
|
||||
self.client = app.test_client()
|
||||
|
||||
def test_home_route(self):
|
||||
"""Test that the home route returns the expected message."""
|
||||
response = self.client.get("/")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response.json, {"message": "Hello, Flask!"})
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم