Skip to main content

AI-powered tool to automatically generate compliant unit tests for FastAPI controllers and service layers, enforcing strict project standards.

Project description

Purpose: The Agent AI tool automatically analyzes FastAPI controller/service files and generates correct unit tests based on strict project rules.

Core Features

-Detect whether the input file is a controller or service -Generate FastAPI test cases with mandatory project standards: -Mock DB Session (MagicMock(spec=Session)) -TestClient with middleware injecting request state -CustomException handler setup -Dependency override for get_db -Cleanup overrides after each test -Ensure success + negative case per endpoint -Follow session-per-request mocking pattern -Handle async + TaskGroup errors (ExceptionGroup) gracefully

Flow- agent_ai -> detect_file_type -> detect_controller_prefix -> run_agent detect_controller_prefix -> get_prefix_for_controller run_agent -> build_prompt -> get_model_client -> generate_response

build_prompt -> extract_schemas_and_modules -> extract_schema_metadata_from_ast

extract_schema_metadata_from_ast -> find_schema_file -> parse_ast_file -> get_schema_type -> extract_fields -> extract_validators

Configuration- It should have MODEL_NAME , MAX_TOKENS , TEMPERATURE , GOOGLE_API_KEY. To change output dir go in run_agent and change it.

All files will be kept at same level in a folder.

Functions list agent-ai.py :- agent_ai agent-services.py :- get_model_client , generate_response , build_prompt, run_agent utilities.py :- extract_schema_metadata_from_ast , find_schema_file , parse_ast_file , get_schema_type ,extract_fields , extract_validators , extract_schemas_and_modules , detect_controller_prefix , get_prefix_for_controller , detect_file_type

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agtest-0.2.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agtest-0.2.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file agtest-0.2.0.tar.gz.

File metadata

  • Download URL: agtest-0.2.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agtest-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1681724e83dcf33b6a026121bb9375cfa18af7906c45a91eb5e9e966ec56a996
MD5 119e4da35d5ee980fbe61ee098d1009d
BLAKE2b-256 25007d00e2fa86769f339ad84124830c31b5da1ad5a359ef36f0c98f60256a7b

See more details on using hashes here.

File details

Details for the file agtest-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agtest-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for agtest-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6588b212e864cc70c1d5fd5c21317a72445f9d6e9077a4b5ed89778d58fa2a6b
MD5 c30ad8d75071ed81b2b004c9da548d7e
BLAKE2b-256 54db94d5a346add49555ae6ddd56d23e07932746ba6c4629e8367eaca23c03d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page