Skip to content

Commit 87497fd

Browse files
committed
[req-changes] Updated runtests and CI
1 parent 2cd2e89 commit 87497fd

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
pip install -U pip wheel setuptools
6565
pip install -U -r requirements-test.txt
6666
pip install -U -e .
67-
pip install -UI --no-deps https://github.com/openwisp/openwisp-utils/tarball/browser-logs
6867
pip install ${{ matrix.django-version }}
6968
7069
- name: Start postgres and redis
@@ -78,11 +77,8 @@ jobs:
7877
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
7978
run: |
8079
coverage run runtests.py --parallel
81-
# the following command runs tests with Postgres/PostGIS but
82-
# only for specific test cases which are tagged with "db_tests"
83-
POSTGRESQL=1 coverage run runtests.py --parallel --keepdb
8480
# tests the extension capability
85-
SAMPLE_APP=1 coverage run ./runtests.py --parallel --keepdb
81+
SAMPLE_APP=1 coverage run ./runtests.py --parallel --keepdb --exclude-tag=selenium_tests
8682
coverage combine
8783
coverage xml
8884
env:

docs/developer/installation.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Launch Redis and PostgreSQL:
4141

4242
.. code-block:: shell
4343
44-
docker-compose up -d redis postgres
44+
docker compose up -d redis postgres
4545
4646
Setup and activate a virtual-environment (we'll be using `virtualenv
4747
<https://pypi.org/project/virtualenv/>`_):
@@ -92,7 +92,8 @@ Launch development server:
9292
9393
You can access the admin interface at ``http://127.0.0.1:8000/admin/``.
9494

95-
Run tests with:
95+
Run tests with (make sure you have the :ref:`selenium dependencies
96+
<selenium_dependencies>` installed locally first):
9697

9798
.. code-block:: shell
9899
@@ -106,9 +107,6 @@ specific tests as follows:
106107

107108
.. code-block:: shell
108109
109-
# Run database tests against PostgreSQL backend
110-
POSTGRESQL=1 ./runtests.py --parallel
111-
112110
# Run only specific selenium tests classes
113111
cd tests/
114112
DJANGO_SETTINGS_MODULE=openwisp2.postgresql_settings ./manage.py test openwisp_controller.config.tests.test_selenium.TestDeviceAdmin
@@ -162,13 +160,13 @@ Build from the Dockerfile:
162160

163161
.. code-block:: shell
164162
165-
docker-compose build
163+
docker compose build
166164
167165
Run the docker container:
168166

169167
.. code-block:: shell
170168
171-
docker-compose up
169+
docker compose up
172170
173171
Troubleshooting Steps for Common Installation Issues
174172
----------------------------------------------------

runtests.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,37 @@
55
import sys
66

77
import pytest
8+
from django.core.management import execute_from_command_line
9+
10+
11+
def run_tests(args, settings_module):
12+
"""
13+
Run Django tests with the specified settings module.
14+
"""
15+
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
16+
execute_from_command_line(args)
17+
818

919
if __name__ == '__main__':
1020
sys.path.insert(0, 'tests')
11-
if os.environ.get('POSTGRESQL', False):
12-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'openwisp2.postgresql_settings')
13-
else:
14-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'openwisp2.settings')
15-
from django.core.management import execute_from_command_line
1621

1722
args = sys.argv
1823
args.insert(1, 'test')
19-
2024
if not os.environ.get('SAMPLE_APP', False):
2125
args.insert(2, 'openwisp_controller')
26+
app_dir = 'openwisp_controller/'
2227
else:
2328
args.insert(2, 'openwisp2')
29+
app_dir = 'tests/openwisp2/'
2430

25-
if os.environ.get('POSTGRESQL', False):
26-
args.extend(['--tag', 'db_tests'])
27-
args.extend(['--tag', 'selenium_tests'])
28-
else:
29-
args.extend(['--exclude-tag', 'selenium_tests'])
30-
31-
execute_from_command_line(args)
31+
# Run all tests except Selenium tests using SQLite
32+
sqlite_args = args.copy()
33+
sqlite_args.extend(['--exclude-tag', 'selenium_tests'])
34+
run_tests(sqlite_args, settings_module='openwisp2.settings')
3235

33-
if not os.environ.get('SAMPLE_APP', False):
34-
app_dir = 'openwisp_controller/'
35-
else:
36-
app_dir = 'tests/openwisp2/'
36+
# Run Selenium tests using PostgreSQL
37+
psql_args = args.copy()
38+
psql_args.extend(['--tag', 'selenium_tests', '--tag', 'db_tests'])
39+
run_tests(psql_args, settings_module='openwisp2.postgresql_settings')
3740

3841
sys.exit(pytest.main([app_dir]))

0 commit comments

Comments
 (0)