forked from DataScientest-Studio/Template_MLOps_accidents
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2cf76dd
commit dade821
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|