Skip to content

Commit 066e06d

Browse files
committed
Merged in master (pull request #20)
merge tests
2 parents 8d22c41 + b3804e1 commit 066e06d

File tree

23 files changed

+13363
-45
lines changed

23 files changed

+13363
-45
lines changed

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
SHELL = /bin/bash
2-
3-
.PHONY: all
2+
.PHONY: tests
43

54
init:
65
cd django && make init
@@ -63,3 +62,7 @@ dump-db:
6362

6463
import-db:
6564
@docker-compose exec pdb sh -c 'psql -U $$POSTGRES_USER $$POSTGRES_DB < /var/services/postgres/var/dump.sql'
65+
66+
tests:
67+
cd django && make tests
68+
cd vue && make tests

django/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
GEMEINDESCAN_WEBUI_DJANGO=0.3.3
1+
GEMEINDESCAN_WEBUI_DJANGO=0.3.4
22
DOCKER_EXEC=$(shell command -v docker > /dev/null && echo "docker-compose exec django")
3-
3+
all: run-tests run-tests-dev
44
.PHONY: all
55
default: dev
66

@@ -29,6 +29,12 @@ migrate:
2929
$(DOCKER_EXEC) python3 manage.py migrate
3030
make collectstatic
3131

32+
tests:
33+
$(DOCKER_EXEC) pytest --create-db
34+
35+
tests-dev:
36+
$(DOCKER_EXEC) pytest --reuse-db -vvv --nomigrations
37+
3238
delete-gemeinden-django:
3339
$(DOCKER_EXEC) python3 manage.py shell --command="from gsmap.models import Municipality;Municipality.objects.all().delete()"
3440

django/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
from django.core.management import call_command
4+
5+
@pytest.fixture(scope='session')
6+
def django_db_setup(django_db_setup, django_db_blocker):
7+
with django_db_blocker.unblock():
8+
call_command('loaddata', 'fixtures-tests/sites.site.json')
9+
call_command('loaddata', 'fixtures-tests/gsuser.user.json')
10+
call_command('loaddata', 'fixtures-tests/gsmap.municipality.json')
11+
call_command('loaddata', 'fixtures-tests/gsmap.snapshot.json')

django/docker/django/requirements/02.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pylint-django==2.0.13
4242
pylint-plugin-utils==0.6
4343
pyparsing==2.4.6
4444
pytest==5.3.5
45+
pytest-django==3.9.0
4546
pytz==2019.3
4647
requests==2.23.0
4748
Rx==1.6.1

django/fixtures-tests/gsmap.municipality.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

django/fixtures-tests/gsmap.snapshot.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"model": "gsuser.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$180000$0wINEkSnlTLQ$cKkWUQGHdT4/pT9KcNzOZ+XS0LNw8Wx4VF4tuZ1oXkE=", "last_login": "2020-05-10T16:16:58.410Z", "is_superuser": true, "username": "admin", "first_name": "", "last_name": "", "email": "[email protected]", "is_staff": true, "is_active": true, "date_joined": "2020-05-10T16:11:16.244Z", "groups": [], "user_permissions": []}}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"model": "sites.site", "pk": 1, "fields": {"domain": "localhost:8081", "name": "localhost:8081"}}]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.0.3 on 2020-05-10 17:42
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('gsmap', '0017_auto_20200429_2118'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='snapshot',
15+
name='id',
16+
field=models.CharField(max_length=8, primary_key=True, serialize=False, unique=True),
17+
),
18+
]

django/gsmap/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from django.contrib.postgres import fields as pg_fields
1111
from django.contrib.sites.models import Site
1212
from django.utils.html import format_html
13+
from django.conf import settings
1314
from sortedm2m.fields import SortedManyToManyField
1415
from sorl.thumbnail import ImageField
1516
from gsuser.models import User
@@ -212,8 +213,8 @@ def save_screenshot():
212213
finally:
213214
# always reconnect signal
214215
post_save.connect(save_screenshot_handler, sender=Snapshot)
215-
216-
save_screenshot()
216+
if hasattr(settings, 'SAVE_SCREENSHOT_ENABLED') and settings.SAVE_SCREENSHOT_ENABLED is True:
217+
save_screenshot()
217218

218219

219220
class Workspace(models.Model):

0 commit comments

Comments
 (0)