File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ pytest~=8.3.3
2
2
httpx ~= 0.27.2
3
3
uvicorn ~= 0.30.2
4
4
gunicorn ~= 19.9.0
5
+ starlette == 0.37.2
Original file line number Diff line number Diff line change 2
2
import os
3
3
import unittest
4
4
from unittest .mock import patch , AsyncMock , MagicMock
5
+ from starlette .testclient import TestClient
5
6
import threading
6
7
import requests
7
8
import time
8
9
sys .path .append (os .path .abspath ('docs/7. Web Applications' ))
9
10
import ex_7_1 as ex1
10
11
import ex_7_2 as ex2
12
+ import ex_7_3 as ex3
11
13
12
14
13
15
class TestGunicornApp (unittest .TestCase ):
@@ -45,5 +47,15 @@ async def test_app_uvicorn(self):
45
47
send_data .assert_any_call (data2_to_send )
46
48
47
49
50
+ class TestStarletteHomepage (unittest .TestCase ):
51
+ def setUp (self ):
52
+ self .client = TestClient (ex3 .app )
53
+
54
+ def test_homepage (self ):
55
+ response = self .client .get ('/' )
56
+ self .assertEqual (response .status_code , 200 )
57
+ self .assertEqual (response .json (), {'hello' : 'world' })
58
+
59
+
48
60
if __name__ == '__main__' :
49
61
unittest .main ()
You can’t perform that action at this time.
0 commit comments