मैनुअल फ़ंक्शनल टेस्ट लिखना

FastAPI परिचय

Matt Eckerle

Software and Data Engineering Leader

फ़ंक्शनल टेस्ट क्या हैं?

सिस्टम टेस्ट

  • फ़ोकस: पृथक सिस्टम ऑपरेशन
  • उद्देश्य: सिस्टम फ़ंक्शन सत्यापित करें
  • स्कोप: एंडपॉइंट
  • पर्यावरण: ऐप चल रहे Python env में
def test_read():
    response = client.get("/items/1")
    assert response.status_code == 200

फ़ंक्शनल टेस्ट

  • फ़ोकस: इंटीग्रेटेड सिस्टम
  • उद्देश्य: पूरे सिस्टम का सत्यापन
  • स्कोप: एप्लिकेशन
  • पर्यावरण: ऐप चल रहे Python env में
def test_delete_then_read():
    response = client.delete("/items/1")
    assert response.status_code == 200
    response = client.get("/items/1")
    assert response.status_code == 404
FastAPI परिचय

टेस्ट वर्कफ़्लो

सफल और असफल टेस्ट वर्कफ़्लो के उदाहरण दिखाते आरेख

FastAPI परिचय

फ़ंक्शनल टेस्ट वर्कफ़्लो उदाहरण

सफल वर्कफ़्लो

  • Create, फिर read
  • Create, फिर update
  • Create, फिर delete
  • ...

असफल वर्कफ़्लो

  • Create के बिना read
  • Delete के बाद update
  • Create के बिना delete
  • ...
FastAPI परिचय

फ़ंक्शनल टेस्ट स्क्रिप्ट्स

  • टेस्ट फ़्रेमवर्क के बाहर - "मैनुअल टेस्ट"
  • requests का उपयोग करें
import requests
ENDPOINT = "http://localhost:8000/items"
# Create item "rock"
r = requests.post(ENDPOINT, json={"name": "rock"})
assert r.status_code == 200
# Get item rock
r = requests.get(ENDPOINT, json={"name": "rock"})
assert r.status_code == 200
  • ज्ञात एप्लिकेशन स्टेट पर आधारित वर्कफ़्लो
FastAPI परिचय

आइए अभ्यास करें!

FastAPI परिचय

Preparing Video For Download...