Skip to content

Commit da9d731

Browse files
ruff format and fix
1 parent 0c840b1 commit da9d731

6 files changed

Lines changed: 19 additions & 14 deletions

File tree

backend/generate_image.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import os
21
import logging
2+
import os
33
from typing import Optional
4+
45
from openai import OpenAI
56

67
logger = logging.getLogger(__name__)

backend/generate_quiz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def check_api_key_from_env(cls) -> None:
8181
os.getenv("DEEPSEEK_API_KEY"),
8282
os.getenv("AZURE_AI_API_KEY"),
8383
]
84-
84+
8585
if not any(api_keys):
8686
raise ValueError(
8787
"No API keys found. Please set at least one of: "

backend/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import os
2+
import sys
33

44
# Add backend directory explicitly
55
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) # Add tests directory

backend/tests/test_generate_image.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
2-
import pytest
32
from types import SimpleNamespace
3+
4+
import pytest
5+
46
from backend.generate_image import ImageGenerator
57

68
"""

backend/tests/test_generate_quiz.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import logging
12
import os
3+
from unittest.mock import MagicMock, patch
4+
25
import pytest
3-
import logging
4-
from unittest.mock import patch, MagicMock
6+
57
from backend.generate_quiz import QuizGenerator
68

79
"""
@@ -50,10 +52,8 @@ def test_environment_variable_not_set(self, monkeypatch):
5052
monkeypatch.delenv("GEMINI_API_KEY", raising=False)
5153
monkeypatch.delenv("DEEPSEEK_API_KEY", raising=False)
5254
monkeypatch.delenv("AZURE_AI_API_KEY", raising=False)
53-
54-
with pytest.raises(
55-
ValueError, match="No API keys found"
56-
):
55+
56+
with pytest.raises(ValueError, match="No API keys found"):
5757
QuizGenerator()
5858

5959
def test_create_role(self, quiz_generator):
@@ -109,7 +109,7 @@ def test_model(self, model):
109109
"""Test each supported model individually."""
110110
# Check if required API keys are available
111111
provider = model.split("/")[0]
112-
112+
113113
if provider == "openai" and not os.getenv("OPENAI_API_KEY"):
114114
pytest.skip("OPENAI_API_KEY not set")
115115
elif provider == "gemini" and not os.getenv("GEMINI_API_KEY"):
@@ -120,12 +120,12 @@ def test_model(self, model):
120120
not os.getenv("AZURE_AI_API_KEY") or not os.getenv("AZURE_AI_API_BASE")
121121
):
122122
pytest.skip("Azure AI credentials not set")
123-
123+
124124
# Test the model
125125
quiz_gen = QuizGenerator(model=model)
126126
gen = quiz_gen.generate_quiz("Math", "Easy", 1)
127127
results = list(gen)
128-
128+
129129
assert len(results) > 0
130130
for r in results:
131131
assert r.startswith("data: ")

backend/tests/test_response_stream_parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import pytest
21
from types import SimpleNamespace
2+
3+
import pytest
4+
35
from backend.response_stream_parser import ResponseStreamParser
46

57
"""

0 commit comments

Comments
 (0)