Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a0ae2b
Add unit tests for backend-api
Shreyas-Microsoft Apr 29, 2026
362ac1f
add asyncio package
Shreyas-Microsoft Apr 29, 2026
98ee6f2
Add processor tests
Shreyas-Microsoft Apr 29, 2026
431830e
update failing tests
Shreyas-Microsoft Apr 29, 2026
3bbe8e8
add more coverage to processor
Shreyas-Microsoft Apr 29, 2026
82d8bc6
fix telemetry test
Shreyas-Microsoft Apr 29, 2026
cccde5f
fix copilot comments and pylint
Shreyas-Microsoft Apr 30, 2026
62dc496
Merge branch 'dev' into psl-unit-testing
Shreyas-Microsoft May 8, 2026
829c51b
ci: simplify coverage comment to badge + total + test summary
Shreyas-Microsoft May 8, 2026
3ecc13d
ci: restore coverage report dropdown in PR comment
Shreyas-Microsoft May 8, 2026
775c5e8
ci: strip per-file details from coverage XML for clean PR comment
Shreyas-Microsoft May 8, 2026
0fb1737
ci: use text coverage summary for TOTAL-only report dropdown
Shreyas-Microsoft May 8, 2026
0810e83
fix: address PR review comments
Shreyas-Microsoft May 8, 2026
63642b6
ci: match reference repo coverage comment format
Shreyas-Microsoft May 8, 2026
d86bcdc
pushing test.yml
Shreyas-Microsoft May 8, 2026
6f0a5b0
test: lift coverage above 82% gate for processor and backend-api
Shreyas-Microsoft May 8, 2026
5457838
test: address Copilot review feedback (PR #211)
Shreyas-Microsoft May 12, 2026
7d45874
test: address Copilot review feedback on test hygiene
Shreyas-Microsoft May 12, 2026
3cd1758
test: fix flake8 E305 in test_sk_logic_base.py
Shreyas-Microsoft May 12, 2026
f42b4f3
fix(infra): remove enableAnalyticalStorage on Cosmos DB account creation
Shreyas-Microsoft May 13, 2026
762f7b7
fix: upgrade vulnerable dependencies (urllib3, python-multipart, auth…
Dhanushree-Microsoft May 14, 2026
4ff9c0f
Merge pull request #211 from microsoft/psl-unit-testing
Roopan-Microsoft May 14, 2026
dd2da35
chore(infra): rebuild main.json with bicep 0.43.8 (restore version)
Shreyas-Microsoft May 14, 2026
0f6b68e
Merge pull request #239 from microsoft/psl-sw/fix-cosmos-analytical-s…
Roopan-Microsoft May 14, 2026
b39d10e
fix: add name/version/private to processor package.json to align with…
Dhanushree-Microsoft May 15, 2026
1960de3
fix: pin override-dependencies to exact versions in processor pyproje…
Dhanushree-Microsoft May 15, 2026
5b6f6fa
Merge pull request #241 from microsoft/con-migdhmoh
Roopan-Microsoft May 15, 2026
222b22c
test: resolve PR #242 review comments
Shreyas-Microsoft May 18, 2026
89b2064
Merge pull request #243 from microsoft/psl-sw/pr242-resolve-comments
Roopan-Microsoft May 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 101 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'src/backend-api/**/*.py'
- 'src/backend-api/pyproject.toml'
- 'src/backend-api/pytest.ini'
- 'src/processor/**/*.py'
- 'src/processor/pyproject.toml'
Comment thread
Shreyas-Microsoft marked this conversation as resolved.
- '.github/workflows/test.yml'
pull_request:
types:
Expand All @@ -23,6 +25,8 @@ on:
- 'src/backend-api/**/*.py'
- 'src/backend-api/pyproject.toml'
- 'src/backend-api/pytest.ini'
- 'src/processor/**/*.py'
- 'src/processor/pyproject.toml'
- '.github/workflows/test.yml'

permissions:
Expand All @@ -36,10 +40,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v6
uses: actions/setup-python@v5
with:
python-version: "3.12"

Expand All @@ -48,7 +52,7 @@ jobs:
python -m pip install --upgrade pip
cd src/backend-api
pip install -e .
pip install pytest pytest-cov
pip install pytest pytest-cov pytest-asyncio

- name: Check if Backend Test Files Exist
id: check_backend_tests
Expand All @@ -71,9 +75,26 @@ jobs:
--cov=src/app \
--cov-report=term-missing \
--cov-report=xml:reports/coverage.xml \
--cov-fail-under=82 \
--junitxml=pytest.xml \
-v

- name: Prefix coverage XML filenames with repo-root path
if: env.skip_backend_tests == 'false'
run: |
python <<'PY'
import xml.etree.ElementTree as ET
path = "src/backend-api/reports/coverage.xml"
prefix = "src/backend-api/src/app/"
tree = ET.parse(path)
root = tree.getroot()
for cls in root.iter("class"):
fname = cls.attrib.get("filename", "")
if fname and not fname.startswith(prefix):
cls.attrib["filename"] = prefix + fname
tree.write(path, xml_declaration=True, encoding="utf-8")
PY

- name: Pytest Coverage Comment
if: |
always() &&
Expand All @@ -90,3 +111,80 @@ jobs:
if: env.skip_backend_tests == 'true'
run: |
echo "Skipping backend tests because no test files were found."

processor_tests:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Processor Dependencies
run: |
python -m pip install --upgrade pip
cd src/processor
pip install -e .
pip install pytest pytest-cov pytest-asyncio

- name: Check if Processor Test Files Exist
id: check_processor_tests
run: |
if [ -z "$(find src/processor/src/tests -type f -name 'test_*.py' 2>/dev/null)" ]; then
echo "No processor test files found, skipping processor tests."
echo "skip_processor_tests=true" >> $GITHUB_ENV
else
echo "Processor test files found, running tests."
echo "skip_processor_tests=false" >> $GITHUB_ENV
fi

- name: Run Processor Tests with Coverage
if: env.skip_processor_tests == 'false'
run: |
cd src/processor
pytest src/tests \
--cov=src \
--cov-report=term-missing \
--cov-report=xml:reports/coverage.xml \
--cov-fail-under=82 \
--junitxml=pytest.xml \
-v

- name: Prefix coverage XML filenames with repo-root path
if: env.skip_processor_tests == 'false'
run: |
python <<'PY'
import xml.etree.ElementTree as ET
path = "src/processor/reports/coverage.xml"
prefix = "src/processor/src/"
tree = ET.parse(path)
root = tree.getroot()
for cls in root.iter("class"):
fname = cls.attrib.get("filename", "")
if fname and not fname.startswith(prefix):
cls.attrib["filename"] = prefix + fname
tree.write(path, xml_declaration=True, encoding="utf-8")
PY

- name: Pytest Coverage Comment (Processor)
if: |
always() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.fork == false &&
env.skip_processor_tests == 'false'
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
with:
pytest-xml-coverage-path: src/processor/reports/coverage.xml
junitxml-path: src/processor/pytest.xml
title: Processor Coverage Report
unique-id-for-comment: processor
report-only-changed-files: true

- name: Skip Processor Tests
if: env.skip_processor_tests == 'true'
run: |
echo "Skipping processor tests because no test files were found."
6 changes: 3 additions & 3 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.43.8.12551",
"templateHash": "7630070384569998511"
"templateHash": "13087590133917597872"
}
},
"parameters": {
Expand Down Expand Up @@ -33853,9 +33853,9 @@
},
"dependsOn": [
"aiFoundryAiServices",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
"virtualNetwork"
]
},
Expand Down
1 change: 0 additions & 1 deletion infra/modules/cosmosDb.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ module cosmosAccount 'br/public:avm/res/document-db/database-account:0.15.1' = {
name: take('avm.res.document-db.account.${name}', 64)
params: {
name: name
enableAnalyticalStorage: true
location: location
minimumTlsVersion: 'Tls12'
defaultConsistencyLevel: 'Session'
Expand Down
9 changes: 6 additions & 3 deletions src/backend-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,26 @@ dependencies = [
"httpx==0.28.1",
"pydantic-settings==2.10.1",
"python-dotenv==1.2.2",
"python-multipart==0.0.26",
"python-multipart==0.0.27",
"protobuf==7.34.0",
"sas-cosmosdb==0.1.4",
"semantic-kernel[azure]==1.40.0",
"uvicorn==0.35.0",
]

[dependency-groups]
dev = ["pytest>=9.0.3", "pytest-cov>=6.2.1"]
dev = ["pytest>=9.0.3", "pytest-cov>=6.2.1", "pytest-asyncio>=0.23.0"]

[tool.coverage.run]
omit = ["src/tests/*"]

[tool.uv]
override-dependencies = [
"av==16.0.0",
"starlette==0.49.1",
"aiohttp==3.13.4",
"azure-core==1.38.0",
"urllib3==2.6.3",
"urllib3==2.7.0",
"requests==2.33.0",
"werkzeug==3.1.4",
"pygments==2.20.0",
Expand Down
38 changes: 38 additions & 0 deletions src/backend-api/src/tests/application/test_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""Tests for application.Application bootstrap."""

from application import Application
from libs.base.typed_fastapi import TypedFastAPI
from libs.services.interfaces import IDataService, IHttpService, ILoggerService
from libs.services.process_services import ProcessService


def test_application_initializes_typed_fastapi():
app = Application()
assert isinstance(app.app, TypedFastAPI)
assert app.app.title == "FastAPI Application"
assert app.app.version == "1.0.0"


def test_application_sets_app_context_on_app():
app = Application()
assert app.app.app_context is app.application_context


def test_application_registers_core_services():
app = Application()
ctx = app.application_context
assert ctx.get_service(ILoggerService) is not None
assert ctx.get_service(IHttpService) is not None
assert ctx.get_service(IDataService) is not None
assert ctx.get_service(ProcessService) is not None


def test_application_includes_routers():
app = Application()
paths = {route.path for route in app.app.routes}
# router_files
assert "/api/file/upload" in paths
# router_process
assert "/api/process/create" in paths
# http_probes
assert "/health" in paths
Loading
Loading