Skip to content

Commit

Permalink
[chores] Re-organized test project
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Dec 16, 2021
1 parent 565d460 commit 166835b
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 27 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,22 @@ jobs:
libsqlite3-mod-spatialite \
gdal-bin
- name: Upgrade python system packages
run: pip install -U "pip==20.2.4" wheel

- name: Install python dependencies
run: pip install --no-cache -U -r requirements-test.txt
run: pip install -U -r requirements-test.txt

- name: Install npm dependencies
run: sudo npm install -g jslint

- name: Installing django-loci
run: |
pip install -e .
pip install --no-cache -U ${{ matrix.django-version }}
pip uninstall -y django-compress-staticfiles
pip install -U -e .
pip install -U ${{ matrix.django-version }}
- name: QA checks
run: ./run-qa-checks

- name: Tests
run: |
pytest --cov=django_loci
coverage run --source=django_loci runtests.py
- name: Upload Coverage
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pytest]
addopts = --create-db --reuse-db --nomigrations django_loci/tests
DJANGO_SETTINGS_MODULE = tests.settings
DJANGO_SETTINGS_MODULE = openwisp2.settings
python_files = pytest_*.py
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
django>=2.2,<3.2
channels~=3.0.0
django>=2.2,<4.1.0
channels>=2.3.0,<2.5.0
django-leaflet~=0.28.0
Pillow~=8.2.0
openwisp-utils @ https://github.com/openwisp/openwisp-utils/tarball/master
Expand Down
12 changes: 7 additions & 5 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import os
import sys

sys.path.insert(0, "tests")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
sys.path.insert(0, 'tests')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'openwisp2.settings')

if __name__ == "__main__":
if __name__ == '__main__':
import pytest
from django.core.management import execute_from_command_line

args = sys.argv
args.insert(1, "test")
args.insert(2, "django_loci")
args.insert(1, 'test')
args.insert(2, 'django_loci')
execute_from_command_line(args)
sys.exit(pytest.main([os.path.join('django_loci', 'tests')]))
2 changes: 1 addition & 1 deletion tests/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "openwisp2.settings")

from django.core.management import execute_from_command_line

Expand Down
Empty file added tests/openwisp2/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes
16 changes: 8 additions & 8 deletions tests/settings.py → tests/openwisp2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

ALLOWED_HOSTS = []

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'django-loci.db',
}
}

SPATIALITE_LIBRARY_PATH = 'mod_spatialite.so'

SECRET_KEY = 'fn)t*+$)ugeyip6-#txyy$5wf2ervc0d2n#h)qb)y5@ly$t*@w'
Expand Down Expand Up @@ -47,7 +54,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'urls'
ROOT_URLCONF = 'openwisp2.urls'

ASGI_APPLICATION = "django_loci.channels.routing.channel_routing"
CHANNEL_LAYERS = {"default": {"BACKEND": "channels.layers.InMemoryChannelLayer"}}
Expand Down Expand Up @@ -80,13 +87,6 @@
}
]

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'django-loci.db',
}
}

# local settings must be imported before test runner otherwise they'll be ignored
try:
from .local_settings import *
Expand Down
3 changes: 1 addition & 2 deletions tests/urls.py → tests/openwisp2/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.conf import settings
from django.conf.urls import include
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path
from django.urls import include, path

urlpatterns = [path('admin/', admin.site.urls)]

Expand Down

0 comments on commit 166835b

Please sign in to comment.