aig: Added unit test case - #33
Conversation
Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>
There was a problem hiding this comment.
Pull request overview
Adds a baseline pytest test suite for the AIG component and configures the repo to only collect tests from aig/tests, aiming to provide lightweight unit/API coverage without requiring OpenVINO models or a running ChromaDB.
Changes:
- Add
pytest.inito scope test discovery toaig/tests. - Introduce unit tests for shared utils, metadata helpers, and image decorator helpers.
- Add Flask test-client based API endpoint/security tests plus a
conftest.pythat installs import stubs for heavy deps and adjustssys.path.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pytest.ini | Restricts pytest discovery to aig/tests. |
| aig/tests/test_shared_utils.py | Tests SharedUtils filename and sample-data loading behavior. |
| aig/tests/test_metadata.py | Tests env parsing + image file save/get/remove helpers. |
| aig/tests/test_img_decorator.py | Tests basic ImgDecorator helper behavior and validation. |
| aig/tests/test_api_endpoints.py | Adds Flask test-client API tests for status/version/predef endpoints and method restrictions. |
| aig/tests/README.md | Documents test scope and how to run tests. |
| aig/tests/conftest.py | Adds OpenVINO/ChromaDB import stubs and sets aig/src on sys.path. |
| aig/requirements-test.txt | Adds a test dependency set for running the new tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def test_security_predef_query_ad_rejects_empty_query_before_backend_init(client, monkeypatch): | ||
| def _backend_should_not_be_called(): |
Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>
Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>
| @@ -0,0 +1,82 @@ | |||
| import sys | |||
There was a problem hiding this comment.
Let's add copyright headers for all py files.
| def test_security_predef_query_ad_rejects_empty_query_before_backend_init(client, monkeypatch): | ||
| def _backend_should_not_be_called(): |
| --ignore=aig/src/database/testASE.py | ||
| --ignore=aig/src/database/testchromadb.py |
There was a problem hiding this comment.
Do we really need these files?
In the subsequent PR, we can think of removing these and having unit tests in place as applicable.
| aig/src/database/testchromadb.py | ||
| aig/src/__main__.py | ||
| aig/src/imgproc/img_sample_logo.py | ||
| aig/src/server/aig_server.py No newline at end of file |
There was a problem hiding this comment.
It's good to test aig_server.py the default API end point right?
PULL DESCRIPTION
Basic Info
REFERENCES
Reference URL for issue tracking (JIRA/HSD/Github): <URL to be filled>
Note-1: Depending on complexity of code changes, use the suitable word for complexity: Low/Medium/High
Example: PR for Slim boot loader project with medium complexity can have the label as: ISDM_Medium
CODE MAINTAINABILITY
Maintainer Mandatory (to be filled by PR Reviewer/Approving Maintainer)
QUALITY CHECKS
CODE REVIEW IMPACT
Note P1/P2/P3/P4 denotes severity of defects found (Showstopper/High/Medium/Low) and xx denotes number of defects found
SECURITY CHECKS
Please check if your PR fulfills the following requirements:
Instead, clarify the check condition using defined behaviors. Example:
if (x > INT_MAX-100)instead ofif (x + 100 < x)