]> git.ipfire.org Git - thirdparty/starlette.git/commitdiff
Update test_client doc from README.md 44/head
authorJeff Buttars <jeffbuttars@gmail.com>
Tue, 28 Aug 2018 14:18:17 +0000 (08:18 -0600)
committerJeff Buttars <jeffbuttars@gmail.com>
Tue, 28 Aug 2018 14:18:17 +0000 (08:18 -0600)
docs/test_client.md

index 13ed233611a4aa19b7290d8481101bb371fe0907..1c28a8de9ae458265b40b3b46c81bf540d654bd1 100644 (file)
@@ -3,7 +3,8 @@ The test client allows you to make requests against your ASGI application,
 using the `requests` library.
 
 ```python
-from starlette import HTMLResponse, TestClient
+from starlette.response import HTMLResponse
+from starlette.testclient import TestClient
 
 
 class App:
@@ -51,7 +52,7 @@ class App:
 
 def test_app():
     client = TestClient(App)
-    with client.wsconnect('/') as session:
+    with client.websocket_connect('/') as session:
         data = session.receive_text()
         assert data == 'Hello, world!'
 ```
@@ -65,10 +66,16 @@ always raised by the test client.
 
 #### Establishing a test session
 
-* `.wsconnect(url, subprotocols=None, **options)` - Takes the same set of arguments as `requests.get()`.
+* `.websocket_connect(url, subprotocols=None, **options)` - Takes the same set of arguments as `requests.get()`.
 
 May raise `starlette.websockets.Disconnect` if the application does not accept the websocket connection.
 
+#### Sending data
+
+* `.send_text(data)` - Send the given text to the application.
+* `.send_bytes(data)` - Send the given bytes to the application.
+* `.send_json(data)` - Send the given data to the application.
+
 #### Receiving data
 
 * `.receive_text()` - Wait for incoming text sent by the application and return it.