Skip to content

Commit

Permalink
Made Readme, improved tests for better compatibility with client, imp…
Browse files Browse the repository at this point in the history
…roved requirements.txt.
  • Loading branch information
inecsor committed Dec 13, 2023
1 parent 868f0a6 commit 67c101d
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 17 deletions.
File renamed without changes.
35 changes: 35 additions & 0 deletions tests/TEST-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Installation & Test Execution Guide

## 1. Setting Up Dependencies
Before launching tests, you need to install the required dependencies. There are two options:
### A. Using the current environment:
```bash
pip install -r misc/requirements.txt
```
### B. Creating a separate Conda environment:
```bash
conda create --name facesdk_python_tests python=3.8
```
```bash
conda activate facesdk_python_tests
pip install -r misc/requirements.txt
```

## 2. Running the Tests

Run the tests using:
```bash
pytest -v
```

## 3. Configuration
Ensure you refer to the file `tests/misc/paths_and_urls.py` for paths to images and service URLs. Make sure to use the correct URL.

## 4. Generating Allure Report
You can access the run using report portal on http://172.20.40.141:8080/

To run tests with report portal use
```bash
pytest -v --reportportal
```
Happy Testing!
10 changes: 2 additions & 8 deletions tests/Tests_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from regula.facesdk.webclient.gen.model.detect_request import DetectRequest
from regula.facesdk.webclient.gen.model.process_param import ProcessParam
from regula.facesdk.webclient.gen.model.crop import Crop
from misc.paths_and_urls import *
from tests.misc.paths_and_urls import *
import pytest
import base64

Expand Down Expand Up @@ -75,13 +75,12 @@ def test_outputImageParams(facesdk, detect_setup):


def test_quality(facesdk, detect_setup):
attributes = DetectRequestAttributes(config=[{'name': 'Age', 'range': [5, 45]}])
quality_request = QualityRequest(
background_match_color=[128, 128, 128],
config=[{"name": "Roll", "range": [-5, 5]}]
)
params = ProcessParam(quality=quality_request)
request = DetectRequest(image=detect_setup[1], process_param=params, attributes=attributes)
request = DetectRequest(image=detect_setup[1], process_param=params)
response = create_dictionary(facesdk.matching_api.detect(request))
basic_assertions(response)
detection = response['results']['detections'][0]
Expand All @@ -101,8 +100,3 @@ def test_attributes(facesdk, detect_setup):
assert attribute_details[0]['name'] == 'Age'
assert 5 <= attribute_details[0]['value'][0] <= 45
assert 5 <= attribute_details[0]['value'][1] <= 45


def test_without_attributes(facesdk, detect_setup):
request = DetectRequest(image=detect_setup[0])
facesdk.matching_api.detect(request)
2 changes: 1 addition & 1 deletion tests/Tests_group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from regula.facesdk.webclient.gen.model.group_to_create import GroupToCreate
from regula.facesdk.webclient.gen.model.person_fields import PersonFields
from regula.facesdk.webclient.gen.model.update_group import UpdateGroup
from misc.paths_and_urls import *
from tests.misc.paths_and_urls import *
import pytest

test_group_name = "test"
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests_matching.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from regula.facesdk.webclient.gen.model.image_source import ImageSource
from regula.facesdk.webclient import MatchImage, MatchRequest
from misc.paths_and_urls import *
from tests.misc.paths_and_urls import *


def validate_response(response, expected_detections_count, expected_first, expected_second=None):
Expand Down
6 changes: 3 additions & 3 deletions tests/Tests_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from regula.facesdk.webclient.gen.model.person_fields import PersonFields
import regula

from misc.paths_and_urls import *
from tests.misc.paths_and_urls import *
import pytest

test_name = "test"
Expand Down Expand Up @@ -78,8 +78,8 @@ def test_get_person_images(group_and_person_setup):
response = facesdk.person_api.get_all_images_by_person_id(page=1, size=1, person_id=person_id)
response_dict = create_dictionary(response)
assert 'items' in response_dict, "'items' key not found in the response dictionary"
assert "id" in response_dict["items"], 'id of photo not found'
assert "path" in response_dict["items"], 'path of photo not found'
assert "id" in response_dict["items"][0], 'id of photo not found'
assert "path" in response_dict["items"][0], 'path of photo not found'


def test_person_groups(group_and_person_setup):
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from regula.facesdk.webclient.gen.model.search_request import SearchRequest
from regula.facesdk.webclient.gen.model.person_fields import PersonFields
from regula.facesdk.webclient.gen.model.crop import Crop
from misc.paths_and_urls import *
from tests.misc.paths_and_urls import *
import pytest

base_metadata = {'description': 'This is a test group'}
Expand Down
15 changes: 12 additions & 3 deletions tests/misc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
pytest
pytest~=7.4.3
requests
allure-pytest
regula.facesdk.webclient
pytest-reportportal
pytest-reportportal
certifi==2023.7.22
six>=1.10
python-dateutil>=2.5.3
urllib3>=1.26.18
vistir>=0.4.0,<=0.6.1
setuptools>=21.0.0
pipenv-setup
wheel
twine
chardet

0 comments on commit 67c101d

Please sign in to comment.