mirror of
https://github.com/sortedcord/alemno-payments.git
synced 2026-07-22 04:02:49 +05:30
setup dependencies and fix test_job_repositories missing deps
This commit is contained in:
15
app/core/dependencies.py
Normal file
15
app/core/dependencies.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.session import get_db
|
||||
from app.repositories.job_repository import JobRepository
|
||||
from app.services.job_service import JobService
|
||||
|
||||
|
||||
def get_job_repository(db: AsyncSession = Depends(get_db)) -> JobRepository:
|
||||
"""Dependency to retrieve JobRepository"""
|
||||
return JobRepository(db)
|
||||
|
||||
|
||||
def get_job_service(repo: JobRepository = Depends(get_job_repository)) -> JobService:
|
||||
"""Dependency to retrieve JobService"""
|
||||
return JobService(repo)
|
||||
@@ -1,11 +1,20 @@
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
|
||||
class AlemnoException(Exception):
|
||||
"""Base exception for Alemno Payments Application"""
|
||||
pass
|
||||
|
||||
|
||||
class JobNotFoundException(AlemnoException):
|
||||
"""Raised when a job is not found"""
|
||||
def __init__(self, job_id: str):
|
||||
self.job_id = job_id
|
||||
super().__init__(f"Job with ID {job_id} not found")
|
||||
|
||||
|
||||
class InvalidCSVException(AlemnoException):
|
||||
"""Raised when the uploaded CSV is invalid"""
|
||||
def __init__(self, detail: str):
|
||||
self.detail = detail
|
||||
super().__init__(detail)
|
||||
|
||||
Reference in New Issue
Block a user