Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Soumaya-JE authored Oct 4, 2024
1 parent 2cf76dd commit dade821
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/testing/01_test_endpoint_retraining.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
import requests


# Sample credentials for users
VALID_CREDENTIALS_USER1 = ("user1", "datascientest")
VALID_CREDENTIALS_ADMIN = ("admin", "adminsecret")
INVALID_CREDENTIALS = ("user1", "wrongpassword")

# Défine API GATEWAY URL
API_GATEWAY_RETRAIN = "http://localhost:8000/retrain"

# Test the /retrain endpoint with admin credentials
def test_retrain_endpoint_as_admin():
response = requests.post(
url=API_GATEWAY_RETRAIN ,
auth=VALID_CREDENTIALS_ADMIN
)

assert response.status_code == 200
assert response.json() == {"message": "Re-entrainement réussi"}


# Test the /retrain endpoint without admin credentials
def test_retrain_endpoint_as_user():
response = requests.post(
url=API_GATEWAY_RETRAIN ,
auth=VALID_CREDENTIALS_USER1
)

assert response.status_code == 403

0 comments on commit dade821

Please sign in to comment.