-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create tests for account, archives and resources
- Loading branch information
Showing
5 changed files
with
139 additions
and
1 deletion.
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
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
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,33 @@ | ||
import os | ||
import pytest | ||
import sys | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
## Add the current directory to the path | ||
sys.path.append(".") | ||
from api import app | ||
|
||
|
||
class TestAPIAccount: | ||
|
||
client = TestClient(app) | ||
API_URL = os.getenv("API_URL") | ||
|
||
@pytest.mark.parametrize("email, input_pwd, expected_result", [ | ||
("DEMO", "demotest", True), | ||
("wrong@example.com", "badpass", False) | ||
]) | ||
def test_verify_login(self, email, input_pwd, expected_result): | ||
credentials = { | ||
"email": email, | ||
"input_pwd": input_pwd | ||
} | ||
|
||
response = self.client.post( | ||
url=f"{self.API_URL}/account/verify_login/", | ||
json=credentials | ||
) | ||
|
||
assert response.status_code == 200 | ||
assert response.json()["result"] == expected_result |
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,36 @@ | ||
import os | ||
import sys | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
## Add the current directory to the path | ||
sys.path.append(".") | ||
from api import app | ||
|
||
|
||
class TestArchiveClassification: | ||
|
||
client = TestClient(app) | ||
API_URL = os.getenv("API_URL") | ||
|
||
def test_archive_classification_found(self): | ||
response = self.client.get(url=f"{self.API_URL}/archives/classification/") | ||
|
||
assert response.status_code == 200 | ||
assert response.json()["result"] == True | ||
assert response.json()["message"] == "Archive classification found" | ||
assert response.json()["content"] is not None | ||
|
||
|
||
class TestArchiveLabelisation: | ||
|
||
client = TestClient(app) | ||
API_URL = os.getenv("API_URL") | ||
|
||
def test_archive_labelisation_found(self): | ||
response = self.client.get(url=f"{self.API_URL}/archives/labelisation/") | ||
|
||
assert response.status_code == 200 | ||
assert response.json()["result"] == True | ||
assert response.json()["message"] == "Archive labelisation found" | ||
assert response.json()["content"] is not None |
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,48 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
# ============================================================================== | ||
# Created By : Charley ∆. Lebarbier | ||
# Date Created : Thursday 2 May 2024 | ||
# ============================================================================== | ||
|
||
import os | ||
import sys | ||
|
||
from fastapi.testclient import TestClient | ||
|
||
## Add the current directory to the path | ||
sys.path.append(".") | ||
from api import app | ||
|
||
|
||
class TestAPIResources: | ||
|
||
client = TestClient(app) | ||
API_URL = os.getenv("API_URL") | ||
|
||
def test_all_glyphs(self): | ||
response = self.client.get(url=f"{self.API_URL}/resources/glyphs/") | ||
|
||
assert response.status_code == 200 | ||
assert isinstance(response.json(), dict) | ||
assert len(response.json()) > 0 and len(response.json()) <= 907 | ||
|
||
|
||
def test_glyph_by_mzl(self): | ||
mzl_number = 13 | ||
expected_response = { | ||
"mzl_number": 13, | ||
"glyph_name": "MUG@g", | ||
"glyph": "𒈯", | ||
"glyph_phonetic": [ | ||
"uttu₄", | ||
"uṭu₄", | ||
"zadim" | ||
] | ||
} | ||
|
||
response = self.client.get(url=f"{self.API_URL}/resources/glyphs/{mzl_number}/") | ||
|
||
assert response.status_code == 200 | ||
assert isinstance(response.json(), dict) | ||
assert response.json() == expected_response |