first push
This commit is contained in:
0
backend/tests/test_agents.py
Normal file
0
backend/tests/test_agents.py
Normal file
28
backend/tests/test_gemma.py
Normal file
28
backend/tests/test_gemma.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import requests
|
||||
|
||||
def tester_gemma():
|
||||
url = "http://localhost:8003/v1/chat/completions"
|
||||
|
||||
payload = {
|
||||
"messages": [
|
||||
{"role": "user", "content": "Donne-moi une astuce de code Python originale."}
|
||||
],
|
||||
"temperature": 0.7
|
||||
}
|
||||
|
||||
print("🧠 Envoi de la requête à Gemma 4...")
|
||||
try:
|
||||
response = requests.post(url, json=payload)
|
||||
response.raise_for_status()
|
||||
answer = response.json()["choices"][0]["message"]["content"]
|
||||
|
||||
print("\n🤖 Réponse de Gemma 4 :")
|
||||
print("-" * 40)
|
||||
print(answer)
|
||||
print("-" * 40)
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur : {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
tester_gemma()
|
||||
10
backend/tests/test_health.py
Normal file
10
backend/tests/test_health.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
def test_health():
|
||||
response = client.get("/api/health")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "ok"
|
||||
55
backend/tests/test_qdrant.py
Normal file
55
backend/tests/test_qdrant.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import asyncio
|
||||
import random
|
||||
from app.repositories.qdrant_repository import QdrantRepository
|
||||
from qdrant_client.http import models
|
||||
|
||||
async def test_pipeline():
|
||||
print("--- Test de connexion Qdrant ---")
|
||||
repo = QdrantRepository()
|
||||
|
||||
try:
|
||||
# 1. Tester la connexion et initialiser la collection
|
||||
await repo.init_collection(vector_size=1024)
|
||||
|
||||
# 2. Insérer un faux projet pour valider le fonctionnement (Upsert)
|
||||
print("\n[Test] Insertion d'un faux projet indexé...")
|
||||
mock_vector = [random.uniform(-1.0, 1.0) for _ in range(1024)]
|
||||
|
||||
await repo.client.upsert(
|
||||
collection_name=repo.collection_name,
|
||||
points=[
|
||||
models.PointStruct(
|
||||
id=1,
|
||||
vector=mock_vector,
|
||||
payload={
|
||||
"title": "Application E-commerce de test",
|
||||
"description": "Un projet test généré pour valider Qdrant",
|
||||
"git_url": "https://github.com/test/test"
|
||||
}
|
||||
)
|
||||
]
|
||||
)
|
||||
print("[Test] Faux projet inséré.")
|
||||
|
||||
# 3. Tester la recherche vectorielle
|
||||
print("\n[Test] Lancement de la recherche vectorielle...")
|
||||
project_found = await repo.search_similar_project(query_vector=mock_vector)
|
||||
|
||||
if project_found:
|
||||
print(f"🎉 Succès ! Projet trouvé en BDD : {project_found['title']} ({project_found['git_url']})")
|
||||
else:
|
||||
print("❌ Erreur : Aucun projet trouvé alors qu'on vient d'en insérer un.")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Échec critique du test : {e}")
|
||||
print("Vérifie que ton conteneur Qdrant est bien lancé et que l'URL dans ton .env est correcte.")
|
||||
|
||||
finally:
|
||||
await repo.close()
|
||||
print("\n--- Fin du test ---")
|
||||
|
||||
if __name__ == "__main__":
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
asyncio.run(test_pipeline())
|
||||
42
backend/tests/test_snowflake.py
Normal file
42
backend/tests/test_snowflake.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
def test_embedding_server():
|
||||
url = "http://localhost:8002/v1/embeddings"
|
||||
|
||||
phrase = "Ceci est un test."
|
||||
|
||||
payload = {
|
||||
"input": phrase
|
||||
}
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
|
||||
print("Envoi de la phrase au serveur Snowflake Arctic local...")
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=payload, headers=headers)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
resultat = response.json()
|
||||
|
||||
vecteur = resultat["data"][0]["embedding"]
|
||||
tokens_utilises = resultat["usage"]["total_tokens"]
|
||||
|
||||
print("\n[SUCCÈS] Le serveur d'embedding répond parfaitement !")
|
||||
print(f"Texte analysé : '{phrase}'")
|
||||
print(f"Nombre de tokens consommés : {tokens_utilises}")
|
||||
print(f"Dimension du vecteur : {len(vecteur)} (Attendu : 768)")
|
||||
print(f"Début du vecteur (5 premiers chiffres) : {vecteur[:5]}")
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
print("\n[ERREUR] Impossible de joindre le serveur d'embedding.")
|
||||
print("Vérifie que ton Docker Compose est bien démarré avec 'docker compose up'.")
|
||||
except Exception as e:
|
||||
print(f"\n[ERREUR] Une erreur inattendue est survenue : {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_embedding_server()
|
||||
0
backend/tests/test_workflow.py
Normal file
0
backend/tests/test_workflow.py
Normal file
Reference in New Issue
Block a user