diff --git a/api/compose/django/dev-entrypoint.sh b/api/compose/django/dev-entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..416207b43d66d6ec7d05b12dd508c33577b8afda --- /dev/null +++ b/api/compose/django/dev-entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +if [ $1 = "pytest" ]; then + # let pytest.ini handle it + unset DJANGO_SETTINGS_MODULE +fi +exec "$@" diff --git a/api/config/settings/test.py b/api/config/settings/test.py index a0b6b2503a1762295c960cae50c06c65c50a4d76..aff29c6571252d1f0d401c550cedf09998a5c512 100644 --- a/api/config/settings/test.py +++ b/api/config/settings/test.py @@ -19,10 +19,6 @@ CACHES = { CELERY_BROKER_URL = 'memory://' -# TESTING -# ------------------------------------------------------------------------------ -TEST_RUNNER = 'django.test.runner.DiscoverRunner' - ########## CELERY # In development, all tasks will be executed locally by blocking until the task returns CELERY_TASK_ALWAYS_EAGER = True @@ -30,3 +26,4 @@ CELERY_TASK_ALWAYS_EAGER = True # Your local stuff: Below this line define 3rd party library settings API_AUTHENTICATION_REQUIRED = False +CACHEOPS_ENABLED = False diff --git a/api/docker-compose.yml b/api/docker-compose.yml deleted file mode 100644 index 4f79eb301b1241c91573c7e4d34d70686f82e7c2..0000000000000000000000000000000000000000 --- a/api/docker-compose.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: '2' -services: - postgres: - image: postgres:9.5 - - api: - build: . - links: - - postgres - - redis - command: ./compose/django/gunicorn.sh - env_file: .env - volumes: - - ./media:/app/funkwhale_api/media - - ./staticfiles:/app/staticfiles - - ./music:/music - ports: - - "127.0.0.1:6001:5000" - - redis: - image: redis:3.0 - - celeryworker: - build: . - env_file: .env - links: - - postgres - - redis - command: celery -A funkwhale_api.taskapp worker -l INFO - volumes: - - ./media:/app/funkwhale_api/media - - ./music:/music - environment: - - C_FORCE_ROOT=True - - celerybeat: - build: . - env_file: .env - links: - - postgres - - redis - command: celery -A funkwhale_api.taskapp beat -l INFO diff --git a/api/docker/Dockerfile.test b/api/docker/Dockerfile.test index 00638e9dd3cb5d290d336698a842f826d73583e9..0990efa512e6a1084249e331e4146f8a223332f5 100644 --- a/api/docker/Dockerfile.test +++ b/api/docker/Dockerfile.test @@ -23,3 +23,4 @@ RUN pip install -r /requirements/test.txt COPY . /app WORKDIR /app +ENTRYPOINT ["compose/django/dev-entrypoint.sh"] diff --git a/api/install_python_dependencies.sh b/api/install_python_dependencies.sh deleted file mode 100755 index 34929e60790b7a6708729fdc35f834d414597da9..0000000000000000000000000000000000000000 --- a/api/install_python_dependencies.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -pip --version >/dev/null 2>&1 || { - echo >&2 -e "\npip is required but it's not installed." - echo >&2 -e "You can install it by running the following command:\n" - echo >&2 "wget https://bootstrap.pypa.io/get-pip.py --output-document=get-pip.py; chmod +x get-pip.py; sudo -H python3 get-pip.py" - echo >&2 -e "\n" - echo >&2 -e "\nFor more information, see pip documentation: https://pip.pypa.io/en/latest/" - exit 1; -} - -virtualenv --version >/dev/null 2>&1 || { - echo >&2 -e "\nvirtualenv is required but it's not installed." - echo >&2 -e "You can install it by running the following command:\n" - echo >&2 "sudo -H pip3 install virtualenv" - echo >&2 -e "\n" - echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/" - exit 1; -} - -if [ -z "$VIRTUAL_ENV" ]; then - echo >&2 -e "\nYou need activate a virtualenv first" - echo >&2 -e 'If you do not have a virtualenv created, run the following command to create and automatically activate a new virtualenv named "venv" on current folder:\n' - echo >&2 -e "virtualenv venv --python=\`which python3\`" - echo >&2 -e "\nTo leave/disable the currently active virtualenv, run the following command:\n" - echo >&2 "deactivate" - echo >&2 -e "\nTo activate the virtualenv again, run the following command:\n" - echo >&2 "source venv/bin/activate" - echo >&2 -e "\nFor more information, see virtualenv documentation: https://virtualenv.pypa.io/en/latest/" - echo >&2 -e "\n" - exit 1; -else - - pip install -r requirements/local.txt - pip install -r requirements/test.txt - pip install -r requirements.txt -fi diff --git a/api/pytest.ini b/api/pytest.ini deleted file mode 100644 index 9be63d3531626526f46f196b840c02a9cae1c8b3..0000000000000000000000000000000000000000 --- a/api/pytest.ini +++ /dev/null @@ -1,6 +0,0 @@ -[pytest] -DJANGO_SETTINGS_MODULE=config.settings.test - -# -- recommended but optional: -python_files = tests.py test_*.py *_tests.py -testpatsh = tests diff --git a/api/requirements/base.txt b/api/requirements/base.txt index 8ec2517be666538892fc2c769fa999503490f29d..bfa1a47db50ffbc21f4eb30e4926306f4953702a 100644 --- a/api/requirements/base.txt +++ b/api/requirements/base.txt @@ -59,3 +59,5 @@ ffmpeg-python==0.1.10 channels>=2,<2.1 channels_redis>=2.1,<2.2 django-cacheops>=4,<4.1 + +daphne==2.0.4 diff --git a/api/requirements/local.txt b/api/requirements/local.txt index b466b20fdfc20c5815fb2f7be8daedccc3f360ac..84680217638aca83169d8148218955f706d2a8e5 100644 --- a/api/requirements/local.txt +++ b/api/requirements/local.txt @@ -3,8 +3,6 @@ coverage>=4.4,<4.5 django_coverage_plugin>=1.5,<1.6 Sphinx>=1.6,<1.7 -django-extensions>=1.9,<1.10 -Werkzeug>=0.13,<0.14 factory_boy>=2.8.1 # django-debug-toolbar that works with Django 1.5+ diff --git a/api/requirements/production.txt b/api/requirements/production.txt index 4ad8edf940dc4524f77c6ac9b339e55c7b1c5a7c..d51ee863ad7e465c5ddcfcf9de5ac8cfcfa51e4f 100644 --- a/api/requirements/production.txt +++ b/api/requirements/production.txt @@ -3,5 +3,3 @@ # WSGI Handler # ------------------------------------------------ - -daphne==2.0.4 diff --git a/api/runtests b/api/runtests deleted file mode 100755 index 48e7b82679e6cab413f4d435cfc0b8f794019bb0..0000000000000000000000000000000000000000 --- a/api/runtests +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -docker-compose -f $DIR/test.yml run test pytest "$@" diff --git a/api/setup.cfg b/api/setup.cfg index c18b80d95bcd54716236d261e572b6b2143d6e3a..954b4d1966887553aaee23b084edbe3ad2833e7c 100644 --- a/api/setup.cfg +++ b/api/setup.cfg @@ -5,3 +5,8 @@ exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules [pep8] max-line-length = 120 exclude=.tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules + +[pytest] +DJANGO_SETTINGS_MODULE=config.settings.test +python_files = tests.py test_*.py *_tests.py +testpaths = tests diff --git a/api/test.yml b/api/test.yml deleted file mode 100644 index 85a3a37f0ed015006cc290aa7edd44dfd95df9a0..0000000000000000000000000000000000000000 --- a/api/test.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '2' -services: - test: - build: - dockerfile: docker/Dockerfile.test - context: . - command: pytest - depends_on: - - postgres - volumes: - - .:/app - environment: - - "DJANGO_ALLOWED_HOSTS=localhost" - - "DATABASE_URL=postgresql://postgres@postgres/postgres" - - "FUNKWHALE_URL=https://funkwhale.test" - - "CACHEOPS_ENABLED=False" - postgres: - image: postgres