Skip to content

Commit

Permalink
new_test and requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
caiquecober committed Dec 24, 2024
1 parent 6f95cca commit ef52cac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ wheel==0.44.0 ; python_version >= "3.11" and python_version < "4.0"
yarl==1.17.1 ; python_version >= "3.11" and python_version < "4.0"
youtube-transcript-api==0.6.2 ; python_version >= "3.11" and python_version < "4.0"
zipp==3.20.2 ; python_version >= "3.11" and python_version < "4.0"
uvicorn==0.23.2 ; python_version >= "3.11" and python_version < "4.0"
fastapi==0.103.0 ; python_version >= "3.11" and python_version < "4.0"
aiohttp==3.11.11 ; python_version >= "3.11" and python_version < "4.0"
pyyaml==6.0.2 ; python_version >= "3.11" and python_version < "4.0"
30 changes: 17 additions & 13 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import os
import pytest
from fastapi.testclient import TestClient
from podcastfy.main import app # Adjust the import based on your FastAPI app location
from podcastfy.api.fast_app import app

client = TestClient(app)

@pytest.fixture
def sample_config():
# Load your sample configuration here
return {
"generate_podcast": True,
"urls": ["https://www.phenomenalworld.org/interviews/swap-structure/"],
Expand All @@ -18,33 +17,38 @@ def sample_config():
"roles_person1": "main summarizer",
"roles_person2": "questioner",
"dialogue_structure": ["Introduction", "Content", "Conclusion"],
"tts_model": "edge", # Specify the edge_tts model here
"tts_model": "edge",
"is_long_form": False,
"engagement_techniques": ["questions", "examples", "analogies"],
"user_instructions": "Dont use the world Dwelve",
"user_instructions": "Don't use the word Dwelve",
"output_language": "English"
}

pytest.mark.skip(reason="Trying to understand if other tests are passing")
def test_generate_podcast_with_edge_tts(sample_config):
"""Test the podcast generation endpoint using the edge_tts model."""
response = client.post("/generate", json=sample_config)

assert response.status_code == 200
assert "audioUrl" in response.json()
assert response.json()["audioUrl"].startswith("http://localhost:8080") # Adjust based on your actual URL
assert response.json()["audioUrl"].startswith("http://localhost:8080")

def test_generate_podcast_invalid_data():
"""Test the podcast generation with invalid data."""
response = client.post("/generate", json={}) # Sending empty data
assert response.status_code == 422 # Unprocessable Entity
response = client.post("/generate", json={})
assert response.status_code == 422

def test_healthcheck():
"""Test the healthcheck endpoint."""
response = client.get("/health")
assert response.status_code == 200
assert response.json() == {"status": "healthy"} # Adjust based on your actual healthcheck response
assert response.json() == {"status": "healthy"}

# Add more tests as needed for other endpoints or functionalities
def test_generate_podcast_with_empty_urls(sample_config):
sample_config["urls"] = []
response = client.post("/generate", json=sample_config)
assert response.status_code == 422

def test_generate_podcast_with_invalid_tts_model(sample_config):
sample_config["tts_model"] = "invalid"
response = client.post("/generate", json=sample_config)
assert response.status_code == 422

if __name__ == "__main__":
pytest.main()

0 comments on commit ef52cac

Please sign in to comment.