Skip to content

Commit 4864a39

Browse files
authored
Merge pull request #56 from john0isaac/restructure-files
Restructure files
2 parents 3c3d0d1 + 8ed5cc7 commit 4864a39

Some content is hidden

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

42 files changed

+43
-31
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
}
5555
},
5656
// Use 'postCreateCommand' to run commands after the container is created.
57-
"postCreateCommand": "pip install -r requirements-dev.txt && pip install -e src",
57+
"postCreateCommand": "pip install -r requirements-dev.txt && pip install -e src/backend",
5858
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5959
"remoteUser": "vscode"
6060
}

.github/workflows/app-tests.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ jobs:
5555
python -m pip install -r requirements-dev.txt
5656
- name: Install app as editable app
5757
run: |
58-
python -m pip install -e src
58+
python -m pip install -e src/backend
5959
- name: Setup local database with seed data
6060
run: |
6161
cp .env.sample .env
62-
python ./src/fastapi_app/setup_postgres_database.py
63-
python ./src/fastapi_app/setup_postgres_seeddata.py
62+
python ./src/backend/fastapi_app/setup_postgres_database.py
63+
python ./src/backend/fastapi_app/setup_postgres_seeddata.py
6464
- name: Setup node
6565
uses: actions/setup-node@v4
6666
with:

README.md

Lines changed: 4 additions & 4 deletions

azure.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
55
services:
66
web:
7-
project: ./src
7+
project: ./src/backend
88
language: py
99
module: web
1010
host: containerapp

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-r src/requirements.txt
1+
-r src/backend/requirements.txt
22
ruff
33
pre-commit
44
pip-tools

scripts/load_python_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ echo 'Creating Python virtual environment in .venv...'
44
python3 -m venv .venv
55

66
echo 'Installing dependencies from "requirements.txt" into virtual environment (in quiet mode)...'
7-
.venv/bin/python -m pip --quiet --disable-pip-version-check install -e src
7+
.venv/bin/python -m pip --quiet --disable-pip-version-check install -e src/backend
88
.venv/bin/python -m pip --quiet --disable-pip-version-check install -r requirements-dev.txt

scripts/setup_postgres_azurerole.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
77
exit 1
88
}
99

10-
python ./src/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
10+
python ./src/backend/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME

scripts/setup_postgres_azurerole.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ fi
99

1010
. ./scripts/load_python_env.sh
1111

12-
.venv/bin/python ./src/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME
12+
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_azurerole.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --app-identity-name $APP_IDENTITY_NAME

scripts/setup_postgres_database.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
77
exit 1
88
}
99

10-
python ./src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
10+
python ./backend/src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD

scripts/setup_postgres_database.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ POSTGRES_DATABASE=$(azd env get-values | grep POSTGRES_DATABASE | sed 's/="/=/'
44

55
. ./scripts/load_python_env.sh
66

7-
.venv/bin/python ./src/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
7+
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_database.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE

scripts/setup_postgres_seeddata.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ if ([string]::IsNullOrEmpty($POSTGRES_HOST) -or [string]::IsNullOrEmpty($POSTGRE
77
exit 1
88
}
99

10-
python ./src/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD
10+
python ./src/backend/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --password $POSTGRES_PASSWORD

scripts/setup_postgres_seeddata.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ POSTGRES_DATABASE=$(azd env get-values | grep POSTGRES_DATABASE | sed 's/="/=/'
44

55
. ./scripts/load_python_env.sh
66

7-
.venv/bin/python ./src/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
7+
.venv/bin/python ./src/backend/fastapi_app/setup_postgres_seeddata.py --host $POSTGRES_HOST --username $POSTGRES_USERNAME --database $POSTGRES_DATABASE
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/frontend/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import react from "@vitejs/plugin-react";
55
export default defineConfig({
66
plugins: [react()],
77
build: {
8-
outDir: "../static",
8+
outDir: "../backend/static",
99
emptyOutDir: true,
1010
sourcemap: true,
1111
rollupOptions: {

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async def create_and_seed_db():
8484
@pytest_asyncio.fixture(scope="session")
8585
async def app(mock_session_env):
8686
"""Create a FastAPI app."""
87-
if not Path("src/static/").exists():
87+
if not Path("src/backend/static/").exists():
8888
pytest.skip("Please generate frontend files first!")
8989
app = create_app(testing=True)
9090
await create_and_seed_db()

tests/mocks.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
from collections import namedtuple
1+
from typing import Any
22

3-
from azure.core.credentials import TokenCredential
4-
5-
MockToken = namedtuple("MockToken", ["token", "expires_on"])
3+
from azure.core.credentials import AccessToken, TokenCredential
64

75

86
class MockAzureCredential(TokenCredential):
9-
def get_token(self, uri):
10-
return MockToken("", 9999999999)
7+
def get_token(
8+
self,
9+
*scopes: str,
10+
claims: str | None = None,
11+
tenant_id: str | None = None,
12+
enable_cae: bool = False,
13+
**kwargs: Any,
14+
) -> AccessToken:
15+
return AccessToken("", 9999999999)
1116

1217

1318
class MockAzureCredentialExpired(TokenCredential):
1419
def __init__(self):
1520
self.access_number = 0
1621

17-
async def get_token(self, uri):
22+
def get_token(
23+
self,
24+
*scopes: str,
25+
claims: str | None = None,
26+
tenant_id: str | None = None,
27+
enable_cae: bool = False,
28+
**kwargs: Any,
29+
) -> AccessToken:
1830
self.access_number += 1
1931
if self.access_number == 1:
20-
return MockToken("", 0)
32+
return AccessToken("", 0)
2133
else:
22-
return MockToken("", 9999999999)
34+
return AccessToken("", 9999999999)

tests/test_frontend_routes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async def test_index(test_client):
88
"""test the index route"""
99
response = test_client.get("/")
1010

11-
html_index_file_path = "src/static/index.html"
11+
html_index_file_path = "src/backend/static/index.html"
1212
with open(html_index_file_path, "rb") as f:
1313
html_index_file = f.read()
1414

@@ -23,7 +23,7 @@ async def test_favicon(test_client):
2323
"""test the favicon route"""
2424
response = test_client.get("/favicon.ico")
2525

26-
favicon_file_path = "src/static/favicon.ico"
26+
favicon_file_path = "src/backend/static/favicon.ico"
2727
with open(favicon_file_path, "rb") as f:
2828
favicon_file = f.read()
2929

@@ -46,7 +46,7 @@ async def test_assets_non_existent_404(test_client):
4646
@pytest.mark.asyncio
4747
async def test_assets(test_client):
4848
"""test the assets route with an existing file"""
49-
assets_dir_path = "src/static/assets"
49+
assets_dir_path = "src/backend/static/assets"
5050
assets_file_path = os.listdir(assets_dir_path)[0]
5151

5252
with open(os.path.join(assets_dir_path, assets_file_path), "rb") as f:

0 commit comments

Comments
 (0)