Compare commits
1 Commits
feature/te
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 8fa72daa6b |
70
makefile
70
makefile
@@ -1,19 +1,67 @@
|
||||
VENV=source .venv/bin/activate;
|
||||
ALLURE=.venv/allure-2.44.0/bin/allure #linux&macos
|
||||
VENV:=source .venv/bin/activate;
|
||||
ALLURE:=.venv/allure-2.44.0/bin/allure #linux&macos
|
||||
#ALLURE=.venv\allure-2.44.0\bin\allure #Windows
|
||||
|
||||
.PHONY:
|
||||
run, m_gen, m_up, allure, coverage, pytest
|
||||
NUM_DOWN ?= 1
|
||||
|
||||
run:
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' Makefile | awk 'BEGIN {FS = ":.*?## "}{printf "[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m## /[33m/' | sed -e 's/\[32m/ [32m/' | sed -e 's/\[33m/[33m/'
|
||||
|
||||
##
|
||||
## Init section
|
||||
##
|
||||
|
||||
.PHONY: run
|
||||
run: ## Run application
|
||||
${VENV} python3 main.py
|
||||
m_gen:
|
||||
|
||||
##
|
||||
## Migration section
|
||||
##
|
||||
|
||||
.PHONY: m_gen
|
||||
m_gen: ## Generate alembic new revision
|
||||
${VENV} alembic revision --autogenerate
|
||||
m_up:
|
||||
|
||||
.PHONY: m_up
|
||||
m_up: ## Set new alembic revision
|
||||
${VENV} alembic upgrade head
|
||||
pytest:
|
||||
|
||||
.PHONY: m_down
|
||||
m_down: ## Downgrade alembic revision
|
||||
${VENV} alembic downgrade -${NUM_DOWN}
|
||||
|
||||
.PHONY: m_history
|
||||
m_history: ## List history of migrations
|
||||
${VENV} alembic history
|
||||
|
||||
.PHONY: m_current
|
||||
m_current: ## Current migration
|
||||
${VENV} alembic current
|
||||
|
||||
.PHONY: m_stamp
|
||||
m_stamp: ## Stamp head
|
||||
${VENV} alembic stamp head
|
||||
|
||||
##
|
||||
## Test section
|
||||
##
|
||||
|
||||
.PHONY: test
|
||||
test: ## Run tests
|
||||
${VENV} pytest
|
||||
allure:
|
||||
|
||||
.PHONY: allure
|
||||
allure: ## Generate allure report
|
||||
${VENV} ${ALLURE} generate tests/allure-results/reports --single-file -o tests/allure-results/html --clean
|
||||
coverage:
|
||||
${VENV} pytest --cov=src tests/
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: ## Run pytest coverage
|
||||
${VENV} pytest --cov=src tests/
|
||||
|
||||
.PHONY: clear
|
||||
clear: ## Delete old test results
|
||||
rm -rf ./tests/allure-results/reports
|
||||
@@ -11,4 +11,30 @@ class Errors:
|
||||
raise HTTPException(status_code=403, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
|
||||
def not_found_error(self, detail:str)->HTTPException:
|
||||
raise HTTPException(status_code=404, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
raise HTTPException(status_code=404, detail=detail, headers={"Cache-Control": "no-store, max-age=0"})
|
||||
|
||||
def conflict_error(self, detail:str)->HTTPException:
|
||||
raise HTTPException(status_code=409, detail=detail)
|
||||
|
||||
def bad_request_error(self, detail:str) -> HTTPException:
|
||||
raise HTTPException(status_code=400, detail=detail)
|
||||
|
||||
def validation_error(self, detail:str) -> HTTPException:
|
||||
raise HTTPException(status_code=422, detail=detail)
|
||||
|
||||
def rate_limit_error(self, detail:str, retry_after: int = 60) -> HTTPException:
|
||||
raise HTTPException(
|
||||
status_code=429,
|
||||
detail=detail,
|
||||
headers={"Retry-After":str(retry_after)}
|
||||
)
|
||||
|
||||
def internal_server_error(self, detail:str = "Internal server error") -> HTTPException:
|
||||
raise HTTPException(status_code=500, detail=detail)
|
||||
|
||||
def service_unavailable_error(self, detail:str, retry_after: int = 30) -> HTTPException:
|
||||
raise HTTPException(
|
||||
status_code=503,
|
||||
detail=detail,
|
||||
headers={"Retry-After":str(retry_after)}
|
||||
)
|
||||
Reference in New Issue
Block a user