mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-08-09 22:44:54 +03:00
bug fixes
This commit is contained in:
commit
f62a2dd06a
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
|
@ -116,19 +116,20 @@ jobs:
|
|||
|
||||
|
||||
production-check:
|
||||
name: "Production check"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [bare, docker]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.11"
|
||||
cache: pip
|
||||
- name: Install Cookiecutter
|
||||
run: pip install cookiecutter
|
||||
- name: Generate project
|
||||
run: cookiecutter . --no-input project_slug=test_project
|
||||
- name: Install project dependencies
|
||||
run: pip install -r test_project/requirements.txt
|
||||
- name: Run Django deployment checks
|
||||
working-directory: test_project
|
||||
run: python manage.py check --deploy
|
||||
cache-dependency-path: |
|
||||
requirements.txt
|
||||
{{cookiecutter.project_slug}}/requirements/base.txt
|
||||
{{cookiecutter.project_slug}}/requirements/local.txt
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
- name: Production check
|
||||
run: sh tests/test_production.sh
|
|
@ -2,7 +2,81 @@ import os
|
|||
import subprocess
|
||||
|
||||
|
||||
def test_production_check():
|
||||
base_dir = os.getcwd()
|
||||
manage_py_path = os.path.join(base_dir, "test_project", "manage.py")
|
||||
subprocess.check_call(['python', manage_py_path, 'check', '--deploy'])
|
||||
def test_production_build():
|
||||
"""Test production build."""
|
||||
# Run production build
|
||||
subprocess.run(["npm", "run", "build"], check=True)
|
||||
|
||||
# Check that the build folder exists
|
||||
assert os.path.isdir("build")
|
||||
|
||||
# Check that the build folder contains the index.html file
|
||||
assert os.path.isfile("build/index.html")
|
||||
|
||||
# Check that the build folder contains the static folder
|
||||
assert os.path.isdir("build/static")
|
||||
|
||||
|
||||
def test_production_build_with_env():
|
||||
"""Test production build with environment variable."""
|
||||
# Set environment variable
|
||||
os.environ["REACT_APP_API_URL"] = "http://localhost:5000"
|
||||
|
||||
# Run production build
|
||||
subprocess.run(["npm", "run", "build"], check=True)
|
||||
|
||||
# Check that the build folder exists
|
||||
assert os.path.isdir("build")
|
||||
|
||||
# Check that the build folder contains the index.html file
|
||||
assert os.path.isfile("build/index.html")
|
||||
|
||||
# Check that the build folder contains the static folder
|
||||
assert os.path.isdir("build/static")
|
||||
|
||||
# Unset environment variable
|
||||
del os.environ["REACT_APP_API_URL"]
|
||||
|
||||
|
||||
def test_production_build_with_env_and_no_api_url():
|
||||
"""Test production build with environment variable and no API URL."""
|
||||
# Set environment variable
|
||||
os.environ["REACT_APP_API_URL"] = ""
|
||||
|
||||
# Run production build
|
||||
subprocess.run(["npm", "run", "build"], check=True)
|
||||
|
||||
# Check that the build folder exists
|
||||
assert os.path.isdir("build")
|
||||
|
||||
# Check that the build folder contains the index.html file
|
||||
assert os.path.isfile("build/index.html")
|
||||
|
||||
# Check that the build folder contains the static folder
|
||||
assert os.path.isdir("build/static")
|
||||
|
||||
# Unset environment variable
|
||||
del os.environ["REACT_APP_API_URL"]
|
||||
|
||||
|
||||
def test_production_build_with_env_and_invalid_api_url():
|
||||
"""Test production build with environment variable and invalid API URL."""
|
||||
# Set environment variable
|
||||
os.environ["REACT_APP_API_URL"] = "invalid"
|
||||
|
||||
# Run production build
|
||||
subprocess.run(["npm", "run", "build"], check=True)
|
||||
|
||||
# Check that the build folder exists
|
||||
assert os.path.isdir("build")
|
||||
|
||||
# Check that the build folder contains the index.html file
|
||||
assert os.path.isfile("build/index.html")
|
||||
|
||||
# Check that the build folder contains the static folder
|
||||
assert os.path.isdir("build/static")
|
||||
|
||||
# Unset environment variable
|
||||
del os.environ["REACT_APP_API_URL"]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user