Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AditiR-42 committed Dec 12, 2024
1 parent 73444ff commit a244460
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/models/tests/integration/test_api_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,15 @@ def test_summarize_endpoint_valid_payload(mock_post):
# Mock the HTTP response
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"summary": "This is a summarized text"}
mock_response.json.return_value = {"summary": "This is a summarized text."}
mock_post.return_value = mock_response

# Send a valid request to the /summarize endpoint
payload = {"text": "This is a long text that needs summarization."}
response = httpx.post(f"{BASE_URL}/summarize", json=payload)

# Assertions
assert response.status_code == 200
assert response.json() == {"summary": "This is a summarized text"}


@patch("httpx.post")
def test_summarize_endpoint_empty_payload(mock_post):
"""Test /summarize endpoint with an empty payload."""
Expand All @@ -435,16 +432,13 @@ def test_summarize_endpoint_empty_payload(mock_post):
mock_response.status_code = 400
mock_response.json.return_value = {"detail": "Text field is required."}
mock_post.return_value = mock_response

# Send an empty request to the /summarize endpoint
payload = {}
response = httpx.post(f"{BASE_URL}/summarize", json=payload)

# Assertions
assert response.status_code == 400
assert response.json() == {"detail": "Text field is required."}



@patch("httpx.post")
def test_summarize_endpoint_invalid_payload(mock_post):
"""Test /summarize endpoint with invalid payload."""
Expand All @@ -453,16 +447,13 @@ def test_summarize_endpoint_invalid_payload(mock_post):
mock_response.status_code = 422
mock_response.json.return_value = {"detail": "Invalid input format."}
mock_post.return_value = mock_response

# Send an invalid request to the /summarize endpoint
payload = {"invalid_key": "value"}
response = httpx.post(f"{BASE_URL}/summarize", json=payload)

# Assertions
assert response.status_code == 422
assert response.json() == {"detail": "Invalid input format."}


@patch("httpx.post")
def test_summarize_endpoint_large_payload(mock_post):
"""Test /summarize endpoint with a large text payload."""
Expand All @@ -471,12 +462,10 @@ def test_summarize_endpoint_large_payload(mock_post):
mock_response.status_code = 200
mock_response.json.return_value = {"summary": "This is a summarized version of a long text."}
mock_post.return_value = mock_response

# Generate a large payload
large_text = "This is a long text. " * 1000 # Repeat to make it large
payload = {"text": large_text}
response = httpx.post(f"{BASE_URL}/summarize", json=payload)

# Assertions
assert response.status_code == 200
assert response.json() == {"summary": "This is a summarized version of a long text."}

0 comments on commit a244460

Please sign in to comment.