diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..d7665eb --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +DATABASE_URL=postgresql+psycopg2://postgres:postgres@localhost:5432/url_db +BASE_URL=http://localhost:8000 +DEBUG=True \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1cd01d9..df27453 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,44 @@ -app/__pycache__ -__pycache__ -.pytest_cache/ +# Environment variables +.env +.env.local +.env.* + +# Keep the example file for setup instructions +!.env.example + +# Virtual environments venv/ +.env/ + +# Python bytecode and cache +__pycache__/ +*.pyc +*.pyo +*.pyd +.python-version + +# Pytest cache +.pytest_cache/ + +# IDE/editor files +.vscode/ +.idea/ +*.swp +*.swo + +# Docker-related files +*.log +docker-compose.override.yml + +# Coverage reports +htmlcov/ +.coverage +coverage.xml + +# Logs +*.log + +# Extras test.txt diff.txt test.db \ No newline at end of file diff --git a/README.md b/README.md index 97f609d..7409153 100644 --- a/README.md +++ b/README.md @@ -40,11 +40,6 @@ http://localhost:9995/docs Test Short URL Endpoint:
http://localhost:9995/shorten -## Run Tests -```bash -pytest --cov=app --cov-report=term-missing -``` - ## Running Alembic revision ```bash cd @@ -55,4 +50,11 @@ alembic revision --autogenerate -m "create urls table" ```bash cd docker compose up --build +``` + +## Running tests in Docker container +```bash +cd +docker compose up --build +docker compose exec app pytest --cov=app --cov-report=term-missing ``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 56b48a7..1b4dcbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,8 @@ services: BASE_URL: http://localhost:9995 ports: - "9995:9995" + volumes: + - .:/app # Mount current directory to /app inside container command: > sh -c "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 9995" diff --git a/requirements.txt b/requirements.txt index 36e12fa..44fedad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,5 @@ pydantic-settings==2.8.1 pytest==8.3.5 pytest-cov==5.0.0 -ruff==0.15.4 \ No newline at end of file +ruff==0.15.4 +httpx==0.24.1 \ No newline at end of file