Skip to content

Commit 2870a21

Browse files
chore: Dev merge to Main
2 parents 5a0efca + 5a8447d commit 2870a21

81 files changed

Lines changed: 13532 additions & 324 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 105 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ on:
88
paths:
99
- 'src/backend-api/**/*.py'
1010
- 'src/backend-api/pyproject.toml'
11+
- 'src/backend-api/uv.lock'
1112
- 'src/backend-api/pytest.ini'
13+
- 'src/processor/**/*.py'
14+
- 'src/processor/pyproject.toml'
15+
- 'src/processor/uv.lock'
1216
- '.github/workflows/test.yml'
1317
pull_request:
1418
types:
@@ -22,7 +26,11 @@ on:
2226
paths:
2327
- 'src/backend-api/**/*.py'
2428
- 'src/backend-api/pyproject.toml'
29+
- 'src/backend-api/uv.lock'
2530
- 'src/backend-api/pytest.ini'
31+
- 'src/processor/**/*.py'
32+
- 'src/processor/pyproject.toml'
33+
- 'src/processor/uv.lock'
2634
- '.github/workflows/test.yml'
2735

2836
permissions:
@@ -36,10 +44,10 @@ jobs:
3644

3745
steps:
3846
- name: Checkout code
39-
uses: actions/checkout@v5
47+
uses: actions/checkout@v4
4048

4149
- name: Set up Python
42-
uses: actions/setup-python@v6
50+
uses: actions/setup-python@v5
4351
with:
4452
python-version: "3.12"
4553

@@ -48,7 +56,7 @@ jobs:
4856
python -m pip install --upgrade pip
4957
cd src/backend-api
5058
pip install -e .
51-
pip install pytest pytest-cov
59+
pip install pytest pytest-cov pytest-asyncio
5260
5361
- name: Check if Backend Test Files Exist
5462
id: check_backend_tests
@@ -71,9 +79,26 @@ jobs:
7179
--cov=src/app \
7280
--cov-report=term-missing \
7381
--cov-report=xml:reports/coverage.xml \
82+
--cov-fail-under=82 \
7483
--junitxml=pytest.xml \
7584
-v
7685
86+
- name: Prefix coverage XML filenames with repo-root path
87+
if: env.skip_backend_tests == 'false'
88+
run: |
89+
python <<'PY'
90+
import xml.etree.ElementTree as ET
91+
path = "src/backend-api/reports/coverage.xml"
92+
prefix = "src/backend-api/src/app/"
93+
tree = ET.parse(path)
94+
root = tree.getroot()
95+
for cls in root.iter("class"):
96+
fname = cls.attrib.get("filename", "")
97+
if fname and not fname.startswith(prefix):
98+
cls.attrib["filename"] = prefix + fname
99+
tree.write(path, xml_declaration=True, encoding="utf-8")
100+
PY
101+
77102
- name: Pytest Coverage Comment
78103
if: |
79104
always() &&
@@ -90,3 +115,80 @@ jobs:
90115
if: env.skip_backend_tests == 'true'
91116
run: |
92117
echo "Skipping backend tests because no test files were found."
118+
119+
processor_tests:
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Python
127+
uses: actions/setup-python@v5
128+
with:
129+
python-version: "3.12"
130+
131+
- name: Install Processor Dependencies
132+
run: |
133+
python -m pip install --upgrade pip
134+
cd src/processor
135+
pip install -e .
136+
pip install pytest pytest-cov pytest-asyncio
137+
138+
- name: Check if Processor Test Files Exist
139+
id: check_processor_tests
140+
run: |
141+
if [ -z "$(find src/processor/src/tests -type f -name 'test_*.py' 2>/dev/null)" ]; then
142+
echo "No processor test files found, skipping processor tests."
143+
echo "skip_processor_tests=true" >> $GITHUB_ENV
144+
else
145+
echo "Processor test files found, running tests."
146+
echo "skip_processor_tests=false" >> $GITHUB_ENV
147+
fi
148+
149+
- name: Run Processor Tests with Coverage
150+
if: env.skip_processor_tests == 'false'
151+
run: |
152+
cd src/processor
153+
pytest src/tests \
154+
--cov=src \
155+
--cov-report=term-missing \
156+
--cov-report=xml:reports/coverage.xml \
157+
--cov-fail-under=82 \
158+
--junitxml=pytest.xml \
159+
-v
160+
161+
- name: Prefix coverage XML filenames with repo-root path
162+
if: env.skip_processor_tests == 'false'
163+
run: |
164+
python <<'PY'
165+
import xml.etree.ElementTree as ET
166+
path = "src/processor/reports/coverage.xml"
167+
prefix = "src/processor/src/"
168+
tree = ET.parse(path)
169+
root = tree.getroot()
170+
for cls in root.iter("class"):
171+
fname = cls.attrib.get("filename", "")
172+
if fname and not fname.startswith(prefix):
173+
cls.attrib["filename"] = prefix + fname
174+
tree.write(path, xml_declaration=True, encoding="utf-8")
175+
PY
176+
177+
- name: Pytest Coverage Comment (Processor)
178+
if: |
179+
always() &&
180+
github.event_name == 'pull_request' &&
181+
github.event.pull_request.head.repo.fork == false &&
182+
env.skip_processor_tests == 'false'
183+
uses: MishaKav/pytest-coverage-comment@26f986d2599c288bb62f623d29c2da98609e9cd4 # v1.6.0
184+
with:
185+
pytest-xml-coverage-path: src/processor/reports/coverage.xml
186+
junitxml-path: src/processor/pytest.xml
187+
title: Processor Coverage Report
188+
unique-id-for-comment: processor
189+
report-only-changed-files: true
190+
191+
- name: Skip Processor Tests
192+
if: env.skip_processor_tests == 'true'
193+
run: |
194+
echo "Skipping processor tests because no test files were found."

infra/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ module aiFoundryAiServices 'br/public:avm/res/cognitive-services/account:0.13.2'
872872
principalType: 'ServicePrincipal'
873873
}
874874
{
875-
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
875+
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Foundry User
876876
principalId: appIdentity.outputs.principalId
877877
principalType: 'ServicePrincipal'
878878
}

infra/main.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.43.8.12551",
9-
"templateHash": "7630070384569998511"
9+
"templateHash": "13087590133917597872"
1010
}
1111
},
1212
"parameters": {
@@ -33853,9 +33853,9 @@
3385333853
},
3385433854
"dependsOn": [
3385533855
"aiFoundryAiServices",
33856-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
33857-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
3385833856
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
33857+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
33858+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
3385933859
"virtualNetwork"
3386033860
]
3386133861
},

infra/main_custom.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ module existingAiFoundryAiServicesDeployments 'modules/ai-services-deployments.b
760760
{
761761
principalId: appIdentity.outputs.principalId
762762
principalType: 'ServicePrincipal'
763-
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
763+
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Foundry User
764764
}
765765
]
766766
}
@@ -814,7 +814,7 @@ module aiFoundryAiServices 'br/public:avm/res/cognitive-services/account:0.13.2'
814814
principalType: 'ServicePrincipal'
815815
}
816816
{
817-
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Azure AI User
817+
roleDefinitionIdOrName: '53ca6127-db72-4b80-b1b0-d745d6d5456d' // Foundry User
818818
principalId: appIdentity.outputs.principalId
819819
principalType: 'ServicePrincipal'
820820
}

infra/modules/cosmosDb.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ module cosmosAccount 'br/public:avm/res/document-db/database-account:0.15.1' = {
4949
name: take('avm.res.document-db.account.${name}', 64)
5050
params: {
5151
name: name
52-
enableAnalyticalStorage: true
5352
location: location
5453
minimumTlsVersion: 'Tls12'
5554
defaultConsistencyLevel: 'Session'

src/backend-api/pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,26 @@ dependencies = [
1717
"httpx==0.28.1",
1818
"pydantic-settings==2.10.1",
1919
"python-dotenv==1.2.2",
20-
"python-multipart==0.0.26",
20+
"python-multipart==0.0.27",
2121
"protobuf==7.34.0",
2222
"sas-cosmosdb==0.1.4",
2323
"semantic-kernel[azure]==1.40.0",
2424
"uvicorn==0.35.0",
2525
]
2626

2727
[dependency-groups]
28-
dev = ["pytest>=9.0.3", "pytest-cov>=6.2.1"]
28+
dev = ["pytest>=9.0.3", "pytest-cov>=6.2.1", "pytest-asyncio>=0.23.0"]
29+
30+
[tool.coverage.run]
31+
omit = ["src/tests/*"]
2932

3033
[tool.uv]
3134
override-dependencies = [
3235
"av==16.0.0",
3336
"starlette==0.49.1",
3437
"aiohttp==3.13.4",
3538
"azure-core==1.38.0",
36-
"urllib3==2.6.3",
39+
"urllib3==2.7.0",
3740
"requests==2.33.0",
3841
"werkzeug==3.1.4",
3942
"pygments==2.20.0",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Tests for application.Application bootstrap."""
2+
3+
from application import Application
4+
from libs.base.typed_fastapi import TypedFastAPI
5+
from libs.services.interfaces import IDataService, IHttpService, ILoggerService
6+
from libs.services.process_services import ProcessService
7+
8+
9+
def test_application_initializes_typed_fastapi():
10+
app = Application()
11+
assert isinstance(app.app, TypedFastAPI)
12+
assert app.app.title == "FastAPI Application"
13+
assert app.app.version == "1.0.0"
14+
15+
16+
def test_application_sets_app_context_on_app():
17+
app = Application()
18+
assert app.app.app_context is app.application_context
19+
20+
21+
def test_application_registers_core_services():
22+
app = Application()
23+
ctx = app.application_context
24+
assert ctx.get_service(ILoggerService) is not None
25+
assert ctx.get_service(IHttpService) is not None
26+
assert ctx.get_service(IDataService) is not None
27+
assert ctx.get_service(ProcessService) is not None
28+
29+
30+
def test_application_includes_routers():
31+
app = Application()
32+
paths = {route.path for route in app.app.routes}
33+
# router_files
34+
assert "/api/file/upload" in paths
35+
# router_process
36+
assert "/api/process/create" in paths
37+
# http_probes
38+
assert "/health" in paths

0 commit comments

Comments
 (0)