Skip to content

Commit d5ff409

Browse files
committed
fix for workflows
1 parent 3539b45 commit d5ff409

File tree

6 files changed

+67
-14
lines changed

6 files changed

+67
-14
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111

1212
- name: Set up Python
13-
uses: actions/setup-python@v4
13+
uses: actions/setup-python@v5
1414
with:
1515
python-version: 3.11
1616

@@ -21,7 +21,10 @@ jobs:
2121
run: uv venv
2222

2323
- name: Install package with dev dependencies
24-
run: uv pip install -e ".[dev,memcached]"
24+
run: uv pip install -e ".[dev]"
2525

2626
- name: Run tests
27-
run: uv run pytest
27+
run: uv run pytest
28+
env:
29+
ENVIRONMENT: local
30+
SECRET_KEY: test-secret-key-for-testing-only

.github/workflows/type-checking.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ jobs:
2424
run: uv pip install -e ".[dev]"
2525

2626
- name: Run mypy
27-
run: uv run mypy src --config-file pyproject.toml
27+
run: uv run mypy src --config-file pyproject.toml
28+
env:
29+
ENVIRONMENT: local
30+
SECRET_KEY: test-secret-key-for-testing-only

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,13 +1838,13 @@ This project uses **fast unit tests** that don't require external services like
18381838

18391839
### 7.1 Writing Tests
18401840

1841-
Create test files with the name `test_{entity}_unit.py` in the `tests/` folder, replacing `{entity}` with what you're testing:
1841+
Create test files with the name `test_{entity}.py` in the `tests/` folder, replacing `{entity}` with what you're testing:
18421842

18431843
```sh
1844-
touch tests/test_items_unit.py
1844+
touch tests/test_items.py
18451845
```
18461846

1847-
Follow the structure in `tests/test_user_unit.py` for examples. Our tests use:
1847+
Follow the structure in `tests/test_user.py` for examples. Our tests use:
18481848

18491849
- **pytest** with **pytest-asyncio** for async support
18501850
- **unittest.mock** for mocking dependencies

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ dependencies = [
2525
"pydantic-settings>=2.0.3",
2626
"redis>=5.0.1",
2727
"arq>=0.25.0",
28-
"gunicorn>=22.0.0",
2928
"bcrypt>=4.1.1",
3029
"psycopg2-binary>=2.9.9",
3130
"fastcrud>=0.15.5",
31+
"gunicorn>=23.0.0",
32+
"ruff>=0.11.13",
33+
"mypy>=1.16.0",
3234
]
3335

3436
[project.optional-dependencies]
@@ -38,6 +40,7 @@ dev = [
3840
"faker>=26.0.0",
3941
"mypy>=1.8.0",
4042
"types-redis>=4.6.0",
43+
"ruff>=0.1.0",
4144
]
4245

4346
[build-system]

src/app/api/v1/tasks.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any
22

33
from arq.jobs import Job as ArqJob
4-
from fastapi import APIRouter, Depends
4+
from fastapi import APIRouter, Depends, HTTPException
55

66
from ...api.dependencies import rate_limiter_dependency
77
from ...core.utils import queue
@@ -24,7 +24,13 @@ async def create_task(message: str) -> dict[str, str]:
2424
dict[str, str]
2525
A dictionary containing the ID of the created task.
2626
"""
27-
job = await queue.pool.enqueue_job("sample_background_task", message) # type: ignore
27+
if queue.pool is None:
28+
raise HTTPException(status_code=503, detail="Queue is not available")
29+
30+
job = await queue.pool.enqueue_job("sample_background_task", message)
31+
if job is None:
32+
raise HTTPException(status_code=500, detail="Failed to create task")
33+
2834
return {"id": job.job_id}
2935

3036

@@ -42,6 +48,11 @@ async def get_task(task_id: str) -> dict[str, Any] | None:
4248
Optional[dict[str, Any]]
4349
A dictionary containing information about the task if found, or None otherwise.
4450
"""
51+
if queue.pool is None:
52+
raise HTTPException(status_code=503, detail="Queue is not available")
53+
4554
job = ArqJob(task_id, queue.pool)
46-
job_info: dict = await job.info()
47-
return vars(job_info)
55+
job_info = await job.info()
56+
if job_info is None:
57+
return None
58+
return job_info.__dict__ if hasattr(job_info, '__dict__') else dict(job_info) if job_info else None

uv.lock

Lines changed: 34 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)