Skip to content

aig: Added unit test case - #33

Open
sathyendranv wants to merge 4 commits into
intel-retail:mainfrom
sathyendranv:feature/test_case
Open

aig: Added unit test case#33
sathyendranv wants to merge 4 commits into
intel-retail:mainfrom
sathyendranv:feature/test_case

Conversation

@sathyendranv

Copy link
Copy Markdown
Contributor

PULL DESCRIPTION

Basic Info

Info Please fill out this column
Environment used (e.g. Ubuntu 20.04)
ROS Version (e.g. Foxy)
Ticket Link (e.g. https://jira.devtools.intel.com/browse/SL6-1100)

REFERENCES

Reference URL for issue tracking (JIRA/HSD/Github): <URL to be filled>

  • Added label to the Pull Request following the template: ISDM_<Complexity>*
    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
  • Added label to the Pull Request for easier discoverability and search

CODE MAINTAINABILITY

  • Commit Message meets guidelines as indicated in the URL* -> defined in Contributing
  • Every commit is a single defect fix and does not mix feature addition or changes*
  • Added required tests -> Added required new tests relevant to the changes
    • PR contains URL links to functional tests executed with the new tests
  • Updated relevant documentation
  • Updated build steps/commands
  • PR change contains code related to security
  • PR introduces breaking change. (If YES, please provide description)
  • Specific instructions or information for code reviewers (If any):

Maintainer Mandatory (to be filled by PR Reviewer/Approving Maintainer)

  • Maintainer who approves the Pull Request for merge is required to mark the checklist below as appropriate for the PR change reviewed as key proof of attestation indicating reasons for merge.
  • Those checklist items which are not marked are considered as not applicable for the PR change.
  • Items marked with an asterisk suffix are mandatory items to check and if not marked will be treated as non-compliant pull requests by the maintainers for ISDM compliance.

QUALITY CHECKS

  • Architectural and Design Fit
  • Quality of code (At least one should be checked as applicable)*
    • Commit Message meets guidelines
    • PR changes adhere to industry practices and standards
    • Upstream expectations are met
    • Adopted domain specific coding standards
    • Error and exception code paths implemented correctly
    • Code reviewed for domain or language specific anti-patterns
    • Code is adequately commented
    • Code copyright is correct
    • Tracing output are minimized and logic
    • Confusing logic is explained in comments
    • Commit comment can be used to design a new test case for the changes
  • Test coverage shows adequate coverage with required CI functional tests pass on all supported platforms*
  • Static code scan report shows zero critical issues*

CODE REVIEW IMPACT

  • Summary of Defects Detected in Code Review: <%P1xx,P2xx,P3xx,P4xx%>
    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:

  • Avoid checks that rely on the result of undefined C behavior.
    Instead, clarify the check condition using defined behaviors. Example: if (x > INT_MAX-100) instead of if (x + 100 < x)
  • Use safe arithmetic to avoid integer overflow.
  • Follow best practices when handling primitive data types
  • Follow security best practices when dealing with pointers
  • Avoid uncontrolled format strings
  • Prevent buffer overflow/underflow
  • Avoid unsafe functions
  • Configure minimal permissions when opening pipes and ports
  • Check contents within input structures are valid before use
  • All forms of input validated
  • Avoid inter-process race conditions
  • Error and exception handling implemented
  • Use keywords and #pragma to constrain gcc compiler optimization
  • Prevent compiler from optimizing out security checks

Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ini to scope test discovery to aig/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.py that installs import stubs for heavy deps and adjusts sys.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.

Comment on lines +164 to +165
def test_security_predef_query_ad_rejects_empty_query_before_backend_init(client, monkeypatch):
def _backend_should_not_be_called():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, please recheck

Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>
Signed-off-by: Vellaisamy, Sathyendran <sathyendran.vellaisamy@intel.com>
@sathyendranv sathyendranv changed the title [WIP] aig: Added test case aig: Added test case Jun 24, 2026
@sathyendranv sathyendranv changed the title aig: Added test case aig: Added unit test case Jun 24, 2026
Comment thread aig/tests/conftest.py
@@ -0,0 +1,82 @@
import sys

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add copyright headers for all py files.

Comment on lines +164 to +165
def test_security_predef_query_ad_rejects_empty_query_before_backend_init(client, monkeypatch):
def _backend_should_not_be_called():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, please recheck

Comment thread pytest.ini
Comment on lines +5 to +6
--ignore=aig/src/database/testASE.py
--ignore=aig/src/database/testchromadb.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need these files?
In the subsequent PR, we can think of removing these and having unit tests in place as applicable.

Comment thread .coveragerc
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to test aig_server.py the default API end point right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants