Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from pathlib import Path

import pytest
from django.conf import settings
from django.contrib.auth.models import User

from allauth.account.models import EmailAddress
from django.contrib.auth.models import User
from rest_framework.test import APIClient
from rest_framework.authtoken.models import Token

import pytest

from pytest_dbfixtures.factories.postgresql import init_postgresql_database
from pytest_dbfixtures.utils import try_import

USERNAME = 'qabel_user'
ADMIN = 'qabel_admin'

Expand Down Expand Up @@ -78,3 +83,17 @@ def user_client(api_client, user):
def external_api_client(user, api_secret):
client = APIClient(HTTP_APISECRET=api_secret)
return client


@pytest.fixture(scope='session', autouse=True)
def apply_database_plumbing(request, postgresql_proc):
"""Bolt pytest-dbfixtures onto Django to work around its lack of no-setup testing facilities."""
psycopg2, config = try_import('psycopg2', request)
settings.DATABASES['default'].update({
'NAME': config.postgresql.db,
'USER': config.postgresql.user,
'HOST': postgresql_proc.host,
'PORT': postgresql_proc.port,
})
init_postgresql_database(psycopg2, config.postgresql.user, postgresql_proc.host, postgresql_proc.port,
config.postgresql.db)
2 changes: 2 additions & 0 deletions qabel_id/settings/base_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,5 @@
OUTGOING_REQUEST_ID_HEADER = 'X-Request-ID'

FACET_USER_PROFILE = False

PROMETHEUS_EXPORT_MIGRATIONS = False
8 changes: 6 additions & 2 deletions qabel_id/settings/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'qabel_index',
'USER': 'qabel',
'PASSWORD': 'qabel_test',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}

Expand Down
6 changes: 6 additions & 0 deletions qabel_provider/migrations/0014_add_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunSQL('SET CONSTRAINTS ALL IMMEDIATE',
reverse_sql=migrations.RunSQL.noop),

# (comments are for forward migration, backwards is the semantic opposite)
migrations.CreateModel(
name='Plan',
Expand Down Expand Up @@ -128,4 +131,7 @@ class Migration(migrations.Migration):
name='profileplanlog',
index_together={('timestamp',), ('profile',)},
),

migrations.RunSQL(migrations.RunSQL.noop,
reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
]
4 changes: 4 additions & 0 deletions qabel_provider/migrations/0015_profile_created_on_behalf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RunSQL(migrations.RunSQL.noop,
reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
migrations.AddField(
model_name='profile',
name='created_on_behalf',
field=models.BooleanField(default=False),
),
migrations.RunSQL(migrations.RunSQL.noop,
reverse_sql='SET CONSTRAINTS ALL IMMEDIATE'),
]
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Markdown==2.6.2
django-filter==0.11.0
-e git://github.com/enkore/django-rest-auth.git@UnignoreMoFiles#egg=django-rest-auth
django-allauth==0.24.1
django-prometheus==1.0.5
django-prometheus==1.0.8
django-cors-middleware==1.2.0
django-axes==1.6.0
django-redis-cache==1.6.5
Expand All @@ -23,3 +23,4 @@ django-bootstrap-form==3.2.1
django-nested-admin==3.0.8
pytz==2016.6.1
django-log-request-id==1.3.1
pytest-dbfixtures==0.13.1