Skip to content

test: Adding missing tests or correcting existing tests#7

Closed
Pavan-Microsoft wants to merge 17 commits intodevfrom
pk-unittest-dev-cwyd
Closed

test: Adding missing tests or correcting existing tests#7
Pavan-Microsoft wants to merge 17 commits intodevfrom
pk-unittest-dev-cwyd

Conversation

@Pavan-Microsoft
Copy link
Owner

Purpose

This pull request adds comprehensive unit tests for several backend modules and utilities, improving test coverage and reliability. It introduces new test modules for authentication utilities, page/chunk combining logic, and admin-related functionality, as well as significant enhancements to citation and markdown URL utilities testing. Additionally, it updates the Python test coverage configuration to provide more detailed output.

New and Enhanced Unit Tests:

  • Authentication utilities:
    • Added test_auth_utils.py with thorough tests for get_authenticated_user_details and get_tenantid, covering various header scenarios, error handling, and edge cases.
  • Page/chunk combining logic:
    • Added test_combine_pages_chunknos.py to test the Azure Function for combining pages and chunk numbers, including normal operation, error handling, and WebApiSkill response structure.
  • Admin and Streamlit utilities:
    • Added test_admin.py for the load_css function, testing file reading, error propagation, and Streamlit integration.
  • Citation and markdown utilities:
    • Expanded test_create_app.py (renamed from test_app.py) to include tests for get_markdown_url and get_citations, verifying URL formatting, SAS token handling, citation parsing, and metadata extraction. [1] [2]

Test Configuration Improvements:

  • Python test coverage:
    • Updated the test workflow to use --cov=code and --cov-report=term-missing for more precise and visible coverage reporting.

Does this introduce a breaking change?

  • Yes
  • No

Harsh-Microsoft and others added 9 commits January 2, 2026 10:20
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Prajwal-Microsoft <v-dcprajwal@microsoft.com>
Co-authored-by: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com>
Co-authored-by: Ajit Padhi <v-padhiajit@microsoft.com>
Co-authored-by: Roopan P M <v-roopanpm@microsoft.com>
Co-authored-by: Pavan-Microsoft <v-kupavan@microsoft.com>
Co-authored-by: Ross Smith <ross-p-smith@users.noreply.github.com>
Co-authored-by: gpickett <122489228+gpickett@users.noreply.github.com>
Co-authored-by: Francia Riesco <friesco@microsoft.com>
Co-authored-by: Francia Riesco <Fr4nc3@users.noreply.github.com>
Co-authored-by: Harmanpreet-Microsoft <v-harmanprka@microsoft.com>
Co-authored-by: UtkarshMishra-Microsoft <v-utkamishra@microsoft.com>
Co-authored-by: Prasanjeet-Microsoft <v-singhprasa@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kiran-Siluveru-Microsoft <v-ksiluveru@microsoft.com>
Co-authored-by: Prashant-Microsoft <v-pmalusare@microsoft.com>
Co-authored-by: Rohini-Microsoft <v-rwalunj@microsoft.com>
Co-authored-by: Avijit-Microsoft <v-aghorui@microsoft.com>
Co-authored-by: RaviKiran-Microsoft <v-ravikirans@microsoft.com>
Co-authored-by: Somesh Joshi <v-somejoshi@microsoft.com>
Co-authored-by: Himanshi Agrawal <v-himagrawal@microsoft.com>
Co-authored-by: pradeepjha-microsoft <v-pradeepjha@microsoft.com>
Co-authored-by: Harmanpreet Kaur <v-harmanpkau@microsoft.com>
Co-authored-by: Bangarraju-Microsoft <v-golib@microsoft.com>
Co-authored-by: Harsh-Microsoft <v-hbangera@microsoft.com>
Co-authored-by: Kanchan-Microsoft <v-knagshetti@microsoft.com>
Co-authored-by: Cristopher Coronado <cristofima@hotmail.com>
Co-authored-by: Cristopher Coronado Moreira <crcorona@pichincha.com>
Co-authored-by: Vamshi-Microsoft <v-vamolla@microsoft.com>
Co-authored-by: Thanusree-Microsoft <168087422+Thanusree-Microsoft@users.noreply.github.com>
Co-authored-by: Niraj Chaudhari (Persistent Systems Inc) <v-nirajcha@microsoft.com>
Co-authored-by: Rohini-Microsoft <168007985+Rohini-Microsoft@users.noreply.github.com>
Co-authored-by: Kingshuk-Microsoft <v-kidatta@microsoft.com>
Co-authored-by: Ayaz-Microsoft <v-ayazkhan@microsoft.com>
Co-authored-by: Abdul-Microsoft <v-amujeebta@microsoft.com>
Co-authored-by: Prekshith-Microsoft <v-pdj@microsoft.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: NirajC-Microsoft <v-nirajcha@microsoft.com>
Co-authored-by: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com>
Co-authored-by: Ajit Padhi <v-padhiajit@microsoft.com>
Co-authored-by: Roopan P M <v-roopanpm@microsoft.com>
Co-authored-by: Pavan-Microsoft <v-kupavan@microsoft.com>
Co-authored-by: Ross Smith <ross-p-smith@users.noreply.github.com>
Co-authored-by: gpickett <122489228+gpickett@users.noreply.github.com>
Co-authored-by: Francia Riesco <friesco@microsoft.com>
Co-authored-by: Francia Riesco <Fr4nc3@users.noreply.github.com>
Co-authored-by: Harmanpreet-Microsoft <v-harmanprka@microsoft.com>
Co-authored-by: UtkarshMishra-Microsoft <v-utkamishra@microsoft.com>
Co-authored-by: Priyanka-Microsoft <v-prisinghal@microsoft.com>
Co-authored-by: Prasanjeet-Microsoft <v-singhprasa@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kiran-Siluveru-Microsoft <v-ksiluveru@microsoft.com>
Co-authored-by: Prashant-Microsoft <v-pmalusare@microsoft.com>
Co-authored-by: Rohini-Microsoft <v-rwalunj@microsoft.com>
Co-authored-by: Avijit-Microsoft <v-aghorui@microsoft.com>
Co-authored-by: RaviKiran-Microsoft <v-ravikirans@microsoft.com>
Co-authored-by: Somesh Joshi <v-somejoshi@microsoft.com>
Co-authored-by: Himanshi Agrawal <v-himagrawal@microsoft.com>
Co-authored-by: pradeepjha-microsoft <v-pradeepjha@microsoft.com>
Co-authored-by: Harmanpreet Kaur <v-harmanpkau@microsoft.com>
Co-authored-by: Bangarraju-Microsoft <v-golib@microsoft.com>
Co-authored-by: Harsh-Microsoft <v-hbangera@microsoft.com>
Co-authored-by: Kanchan-Microsoft <v-knagshetti@microsoft.com>
Co-authored-by: Cristopher Coronado <cristofima@hotmail.com>
Co-authored-by: Cristopher Coronado Moreira <crcorona@pichincha.com>
Co-authored-by: Vamshi-Microsoft <v-vamolla@microsoft.com>
Co-authored-by: Thanusree-Microsoft <168087422+Thanusree-Microsoft@users.noreply.github.com>
Co-authored-by: Rohini-Microsoft <168007985+Rohini-Microsoft@users.noreply.github.com>
Co-authored-by: Kingshuk-Microsoft <v-kidatta@microsoft.com>
Co-authored-by: Ayaz-Microsoft <v-ayazkhan@microsoft.com>
Co-authored-by: Abdul-Microsoft <v-amujeebta@microsoft.com>
Co-authored-by: Prekshith-Microsoft <v-pdj@microsoft.com>
Co-authored-by: Rafi-Microsoft <v-rafmd@microsoft.com>
- Updated test cases in `test_env_helper.py` to set environment variables as strings for boolean values.
- Added multiple test cases in `test_lang_chain_agent.py` to validate content safety input and output handling, including blocking harmful content and ensuring proper memory management with chat history.
- Enhanced `test_open_ai_functions.py` with tests for function calls and content safety validation, ensuring robust handling of various scenarios including unknown function calls and null answers.
- Removed obsolete test file `test_azure_blob_storage_client.py`.
- Expanded `test_content_safety_checker.py` to cover various scenarios for content safety checks, including handling harmful content, safe text validation, and error handling for HTTP responses.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds comprehensive unit tests for several backend modules and utilities, improving test coverage and reliability. The changes include new test modules for authentication, document processing, chat history, and database operations, along with enhancements to existing test suites and an update to the pytest coverage configuration for better output visibility.

Changes:

  • Added comprehensive tests for content safety, Azure Form Recognizer, blob storage, PostgreSQL, authentication utilities, and chat history operations
  • Enhanced existing tests for orchestrators, environment helpers, and CosmosDB operations
  • Updated pytest coverage configuration to use --cov=code and --cov-report=term-missing for more precise reporting

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
.github/workflows/tests.yml Updated pytest coverage arguments for better reporting
test_content_safety_checker.py Added extensive tests for content safety validation with RBAC/key auth
test_azure_blob_storage_client.py Replaced with comprehensive tests covering all blob operations
test_open_ai_functions.py Enhanced with function call orchestration tests
test_lang_chain_agent.py Added tests for agent orchestration scenarios
test_env_helper.py Fixed environment variable type handling
test_azure_postgres_helper.py Added tests for PostgreSQL operations
test_azure_form_recognizer_helper.py New comprehensive tests for document analysis
test_create_app.py Enhanced with citation and markdown URL utility tests
test_combine_pages_chunknos.py New tests for Azure Function page combining
test_chat_history.py Significantly expanded with comprehensive API endpoint tests
test_admin.py New tests for admin module CSS loading
test_database_client_base.py New tests for abstract base class contract
test_cosmosdb.py Enhanced with detailed CosmosDB operation tests
test_auth_utils.py New tests for authentication utility functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Pavan-Microsoft and others added 4 commits January 16, 2026 13:52
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Roopan P M <v-roopanpm@microsoft.com>
Co-authored-by: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com>
Co-authored-by: Pavan-Microsoft <v-kupavan@microsoft.com>
Co-authored-by: Prasanjeet-Microsoft <v-singhprasa@microsoft.com>
Co-authored-by: Harmanpreet Kaur <v-harmanpkau@microsoft.com>
Co-authored-by: Harmanpreet-Microsoft <v-harmanprka@microsoft.com>
@Pavan-Microsoft Pavan-Microsoft marked this pull request as draft January 16, 2026 09:20
@Pavan-Microsoft Pavan-Microsoft deleted the branch dev January 19, 2026 12:26
@Pavan-Microsoft Pavan-Microsoft deleted the pk-unittest-dev-cwyd branch January 19, 2026 12:27
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.

8 participants