Gros refactoring
This commit is contained in:
parent
6008aa68f6
commit
4a6bfc951f
368 changed files with 22503 additions and 3 deletions
101
backend/test-confiance.py
Normal file
101
backend/test-confiance.py
Normal file
|
@ -0,0 +1,101 @@
|
|||
import requests
|
||||
|
||||
# Base URL for the API
|
||||
BASE_URL = "http://127.0.0.1:8000"
|
||||
|
||||
# Function to get the access token
|
||||
def get_access_token():
|
||||
login_url = f"{BASE_URL}/token/"
|
||||
headers = {"Content-Type": "application/x-www-form-urlencoded"}
|
||||
data = {"username": "francois", "password": "password"}
|
||||
|
||||
response = requests.post(login_url, headers=headers, data=data)
|
||||
|
||||
if response.status_code == 200:
|
||||
return response.json()["access_token"]
|
||||
else:
|
||||
raise Exception(f"Login failed: {response.status_code}, {response.text}")
|
||||
|
||||
# Get the access token
|
||||
access_token = get_access_token()
|
||||
print(f"Access token: {access_token}")
|
||||
|
||||
# Common headers for all requests
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": f"Bearer {access_token}"
|
||||
}
|
||||
|
||||
# Test cases
|
||||
test_cases = [
|
||||
{
|
||||
"name": "Instagram Story",
|
||||
"accept": "application/zip",
|
||||
"data": {
|
||||
"format": "instagram-story",
|
||||
"style": "consultation-express",
|
||||
"linkcolor": "blue",
|
||||
"pdfengine": "lualatex",
|
||||
"content": "# Ceci est un titre\n## Ceci est un sous-titre\n\nCeci est un paragraphe\n\n## Ceci est un autre sous-titre\n\n> Ceci est du code\n\nCeci est un emoji :heart_eyes:\n\n::: {.center}\nCeci est centré\n:::",
|
||||
"fontsize": 14,
|
||||
"paperwidth": 1080,
|
||||
"paperheight": 1920,
|
||||
"margin": 90,
|
||||
"vmargin": 180,
|
||||
"fps": 15,
|
||||
"stilltime": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Instagram Fullscreen",
|
||||
"accept": "application/zip",
|
||||
"data": {
|
||||
"format": "instagram-fullscreen",
|
||||
"style": "consultation-express",
|
||||
"linkcolor": "blue",
|
||||
"pdfengine": "lualatex",
|
||||
"content": "# Ceci est un titre\n## Ceci est un sous-titre\n\nCeci est un paragraphe\n\n## Ceci est un autre sous-titre\n\n> Ceci est du code\n\nCeci est un emoji :heart_eyes:\n\n::: {.center}\nCeci est centré\n:::",
|
||||
"fontsize": 14,
|
||||
"paperwidth": 1080,
|
||||
"paperheight": 1350,
|
||||
"margin": 90,
|
||||
"vmargin": 180,
|
||||
"fps": 15,
|
||||
"stilltime": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Instagram Carré",
|
||||
"accept": "application/pdf",
|
||||
"data": {
|
||||
"format": "instagram-carre",
|
||||
"style": "consultation-express",
|
||||
"linkcolor": "blue",
|
||||
"pdfengine": "lualatex",
|
||||
"content": "# Ceci est un titre\n## Ceci est un sous-titre\n\nCeci est un paragraphe\n\n## Ceci est un autre sous-titre\n\n> Ceci est du code\n\nCeci est un emoji :heart_eyes:\n\n::: {.center}\nCeci est centré\n:::",
|
||||
"fontsize": 14,
|
||||
"paperwidth": 1080,
|
||||
"paperheight": 1080,
|
||||
"margin": 90,
|
||||
"vmargin": 180,
|
||||
"fps": 15,
|
||||
"stilltime": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
# Run tests
|
||||
for test in test_cases:
|
||||
print(f"\nRunning test: {test['name']}")
|
||||
headers["Accept"] = test["accept"]
|
||||
response = requests.post(f"{BASE_URL}/generer/", headers=headers, json=test["data"])
|
||||
|
||||
print(f"Status code: {response.status_code}")
|
||||
if response.status_code == 200:
|
||||
print("Test passed")
|
||||
if test["accept"] == "application/zip":
|
||||
print("Received ZIP file")
|
||||
elif test["accept"] == "application/pdf":
|
||||
print("Received PDF file")
|
||||
else:
|
||||
print(f"Test failed: {response.text}")
|
Loading…
Add table
Add a link
Reference in a new issue