INNER CODE UNIT · Python
test_api
mongodb-developer/mongodb-with-fastapi · test_api.py:4
def test_api():
"""
An automated version of the manual testing I've been doing,
testing the lifecycle of an inserted document.
"""
student_root = "http://localhost:8000/students/"
initial_doc = {
"course": "Test Course",
"email": "jdoe_test@example.com",
"gpa": "3.0",
"name": "Jane Doe",
}
try:
# Insert a student
response = post(student_root, json=initial_doc)
response.raise_for_status()