diff --git a/crud_tests/settings.py b/crud_tests/settings.py
index 89b4d20a2..b3d1042dc 100644
--- a/crud_tests/settings.py
+++ b/crud_tests/settings.py
@@ -1,7 +1,12 @@
+import os
+
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': ':memory:',
+ # 'NAME': ':memory:',
+ 'NAME': '/tmp/db',
},
}
@@ -9,6 +14,7 @@ INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.messages',
+ 'django.contrib.sessions',
'crud_tests',
'crispy_forms',
)
@@ -21,9 +27,34 @@ SECRET_KEY = 'zzz...'
TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [os.path.join(BASE_DIR, 'crud_tests/templates'), os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ "django.core.context_processors.media",
+ "django.core.context_processors.static",
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
}]
+STATIC_URL = '/static/'
+
+MIDDLEWARE_CLASSES = (
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ # 'django.middleware.locale.LocaleMiddleware',
+ # 'django.middleware.common.CommonMiddleware',
+ # 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+ # 'django.middleware.security.SecurityMiddleware',
+)
+
SILENCED_SYSTEM_CHECKS = [
'1_7.W001', # Unset MIDDLEWARE_CLASSES warning
]
diff --git a/crud_tests/templates/base.html b/crud_tests/templates/base.html
new file mode 100644
index 000000000..75b4487c2
--- /dev/null
+++ b/crud_tests/templates/base.html
@@ -0,0 +1,43 @@
+{% load i18n %}
+
+
+
+
+
+
+
+
+
+
+
+ {# Feedback messages #}
+ {% for message in messages %}
+
+
+ {{ message|safe }}
+
+ {% endfor %}
+
+ {# Content header #}
+ {% block base_header %}
+
+
+ {% block title %}
+ {% if view.title %}
+
+ {% endif %}
+ {% endblock %}
+
+
+ {% endblock base_header %}
+
+ {# Content per se #}
+ {% block base_content %}{% endblock %}
+
+
+
+
+
+
diff --git a/crud_tests/test_flux.py b/crud_tests/test_flux.py
index d819ae1cb..3f23ae4fc 100644
--- a/crud_tests/test_flux.py
+++ b/crud_tests/test_flux.py
@@ -160,7 +160,6 @@ def assert_on_detail_page(res, stub_name):
assert 'Excluir' in res
-@pytest.mark.urls('sapl.teststubs.urls_for_list_test')
@pytest.mark.parametrize("num_entries, page_size, ranges, page_list", [
(0, 6, [], []),
(5, 5, [(0, 5)], []),
@@ -172,13 +171,17 @@ def test_flux_list_paginate_detail(
entries_labels = []
for i in range(num_entries):
- # letter = next(letters)
name, continent = 'name %s' % i, 'continent %s' % i
- entries_labels.append([name, continent])
- mommy.make(Country, name=name, continent__name=continent)
+ population, is_cold = i, i % 2 == 0
+ entries_labels.append([
+ name, continent, str(population), 'Yes' if is_cold else 'No'])
+ mommy.make(Country,
+ name=name,
+ continent__name=continent,
+ population=population,
+ is_cold=is_cold)
- from .teststubs.urls_for_list_test import crud
- crud.CrudListView.paginate_by = page_size
+ country_crud.CrudListView.paginate_by = page_size
res = app.get('/countries/')
@@ -195,8 +198,8 @@ def test_flux_list_paginate_detail(
table = res.html.find('table')
assert table
header, *trs = table.findAll('tr')
- assert header.text.strip().split() == [
- 'name', 'Sigla', 'continent']
+ assert [c.text for c in header.findChildren('th')] == [
+ 'name', 'continent', 'population', 'is cold']
rows = [[td.text.strip() for td in tr.findAll('td')]
for tr in trs]
@@ -264,11 +267,11 @@ def test_flux_list_create_detail(app, cancel, make_invalid_submit):
# now fill out some fields
form = res.form
- stub_name = '### name Especial ###'
+ stub_name = '### name ###'
form['name'] = stub_name
- form['sigla'] = 'SIGLA'
form['continent'] = stub_continent.id
- form['data_criacao'] = '1/1/2001'
+ form['population'] = 23000
+ form['is_cold'] = True
res = form.submit()
# on redirect to detail page
diff --git a/pytest.ini b/pytest.ini
index 3480351c1..a3b1eef1f 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,6 +1,6 @@
[pytest]
DJANGO_SETTINGS_MODULE=sapl.settings
-norecursedirs = legacy
+norecursedirs = legacy crud_tests
# REUSING DATABASE BY DEFAULT (as a performance optimization)
# http://pytest-django.readthedocs.org/en/latest/database.html#example-work-flow-with-reuse-db-and-create-db
diff --git a/test_and_check_qa.sh b/test_and_check_qa.sh
index c7a01989b..c1753337c 100755
--- a/test_and_check_qa.sh
+++ b/test_and_check_qa.sh
@@ -3,4 +3,5 @@
# QA checks: run this before every commit
py.test
-./qa_check.sh
+py.test --ds=crud_tests.settings crud_tests
+./check_qa.sh