From 593a3c2539d344e57812e6d8f704d1d86fb3aab4 Mon Sep 17 00:00:00 2001 From: Reza Karbasi Date: Wed, 20 Mar 2024 06:04:32 +0330 Subject: [PATCH] add: a test added for 'represent' API endpoint to check the url input This commit adds a new test case for the 'represent' API endpoint. The test verifies that the endpoint correctly processes an image URL and returns the expected data structure, including the correct number of face embeddings, face confidence, and facial area for each detected face in the image. --- tests/test_api.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_api.py b/tests/test_api.py index ab74333..07418d0 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -106,6 +106,29 @@ class TestVerifyEndpoint(unittest.TestCase): logger.info("✅ representation api test is done") + def test_represent_url(self): + data = { + "model_name": "Facenet", + "detector_backend": "mtcnn", + "img": "https://github.com/serengil/deepface/blob/master/tests/dataset/couple.jpg?raw=true" + } + + response = self.app.post("/represent", json=data) + assert response.status_code == 200 + result = response.json + logger.debug(result) + assert result.get("results") is not None + assert isinstance(result["results"], list) is True + assert len(result["results"]) == 2 # 2 faces are in the image link + for i in result["results"]: + assert i.get("embedding") is not None + assert isinstance(i.get("embedding"), list) is True + assert len(i.get("embedding")) == 128 + assert i.get("face_confidence") is not None + assert i.get("facial_area") is not None + + logger.info("✅ representation api test is done") + def test_analyze(self): data = { "img": "dataset/img1.jpg",