Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qodo Cover Update: 1733363098 #19

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions templated_tests/python_fastapi/tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,72 @@ def test_root():
assert response.status_code == 200
assert response.json() == {"message": "Welcome to the FastAPI application!"}


def test_echo():
test_message = "Hello, FastAPI!"
response = client.get(f"/echo/{test_message}")
assert response.status_code == 200
assert response.json() == {"message": test_message}


def test_days_until_new_year():
response = client.get("/days-until-new-year")
assert response.status_code == 200
# Since this test will run on different days, we can't assert the exact number of days.
# Instead, we check if the response contains the correct key.
assert "days_until_new_year" in response.json()


def test_is_palindrome_true():
response = client.get("/is-palindrome/racecar")
assert response.status_code == 200
assert response.json() == {"is_palindrome": True}


def test_square():
response = client.get("/square/4")
assert response.status_code == 200
assert response.json() == {"result": 16}


def test_divide():
response = client.get("/divide/10/2")
assert response.status_code == 200
assert response.json() == {"result": 5.0}


def test_multiply():
response = client.get("/multiply/3/5")
assert response.status_code == 200
assert response.json() == {"result": 15}


def test_subtract():
response = client.get("/subtract/10/4")
assert response.status_code == 200
assert response.json() == {"result": 6}


def test_sqrt_negative_number():
response = client.get("/sqrt/-4")
assert response.status_code == 400
assert response.json() == {"detail": "Cannot take square root of a negative number"}


def test_divide_by_zero():
response = client.get("/divide/10/0")
assert response.status_code == 400
assert response.json() == {"detail": "Cannot divide by zero"}


def test_add():
response = client.get("/add/3/5")
assert response.status_code == 200
assert response.json() == {"result": 8}


def test_current_date():
response = client.get("/current-date")
assert response.status_code == 200
assert response.json() == {"date": date.today().isoformat()}