Permalink
Browse files

Fix testing with new merged sandbox

  • Loading branch information...
1 parent e15539c commit edadcdf4e3d9056170e9bf3855651f2c19c1161d @elbaschid elbaschid committed Jul 15, 2014
View
@@ -17,24 +17,24 @@ env:
matrix:
# Testing against Django 1.4
- - DJANGO="Django>=1.4,<1.5" MODEL_UTILS_VERSION=">2.0" TARGET='test-fancypages'
+ - DJANGO="Django>=1.4,<1.5" MODEL_UTILS_VERSION=">2.0" TARGET='test-standalone-fancypages'
- DJANGO="Django>=1.4,<1.5" MODEL_UTILS_VERSION=">2.0" TARGET='test-oscar-fancypages'
# Testing against Django 1.5
- - DJANGO="Django>=1.5,<1.6" MODEL_UTILS_VERSION="==1.5" TARGET='test-fancypages'
+ - DJANGO="Django>=1.5,<1.6" MODEL_UTILS_VERSION="==1.5" TARGET='test-standalone-fancypages'
- DJANGO="Django>=1.5,<1.6" MODEL_UTILS_VERSION="==1.5" TARGET='test-oscar-fancypages'
# Testing against Django 1.6
- - DJANGO="Django>=1.6,<1.7" MODEL_UTILS_VERSION=">2.0" TARGET='test-fancypages'
+ - DJANGO="Django>=1.6,<1.7" MODEL_UTILS_VERSION=">2.0" TARGET='test-standalone-fancypages'
- DJANGO="Django>=1.6,<1.7" MODEL_UTILS_VERSION=">2.0" TARGET='test-oscar-fancypages'
# Testing against Django 1.7
- - DJANGO="https://github.com/django/django/archive/1.7c1.zip" MODEL_UTILS_VERSION=">2.0" TARGET='test-fancypages'
+ - DJANGO="https://github.com/django/django/archive/1.7c1.zip" MODEL_UTILS_VERSION=">2.0" TARGET='test-standalone-fancypages'
# FIXME: oscar_fancypages currently doesn't support Django 1.7
#- DJANGO="https://github.com/django/django/archive/1.7b4.zip" MODEL_UTILS_VERSION=">2.0" TARGET='test-oscar-fancypages' EXTRA_INSTALLS="git+https://github.com/elbaschid/django-oscar.git@add_support_for_django17#egg=django-oscar-dev"
# We run the browser tests only once to save a bit of time
- - DJANGO="Django>=1.6,<1.7" MODEL_UTILS_VERSION=">2.0" TARGET='test-fancypages' PYTEST_OPTS="-m browser"
+ - DJANGO="Django>=1.6,<1.7" MODEL_UTILS_VERSION=">2.0" TARGET='test-standalone-fancypages' PYTEST_OPTS="-m browser"
before_install:
- "export DISPLAY=:99.0"
View
@@ -37,22 +37,22 @@ test-oscar-fancypages:
test-standalone-postgres:
- psql -h localhost -p ${DJANGO_POSTGRES_PORT} -U postgres -c "DROP DATABASE fp_sandbox;"
psql -h localhost -p ${DJANGO_POSTGRES_PORT} -U postgres -c "CREATE DATABASE fp_sandbox;"
- DJANGO_CONFIGURATION="StandaloneFancypagesPostgres" SANDBOX="fancypages" ./run-migrations.sh
+ DJANGO_CONFIGURATION="StandaloneFancypagesPostgres" ./run-migrations.sh
test-standalone-mysql:
- mysql -h 127.0.0.1 -P ${DJANGO_MYSQL_PORT} -u root -e 'DROP DATABASE fp_sandbox;'
mysql -h 127.0.0.1 -P ${DJANGO_MYSQL_PORT} -u root -e 'CREATE DATABASE fp_sandbox;'
- DJANGO_CONFIGURATION="StandaloneFancypagesMysql" SANDBOX="fancypages" ./run-migrations.sh
+ DJANGO_CONFIGURATION="StandaloneFancypagesMysql" ./run-migrations.sh
test-oscar-postgres:
- psql -h localhost -p ${DJANGO_POSTGRES_PORT} -U postgres -c "DROP DATABASE ofp_sandbox;"
psql -h localhost -p ${DJANGO_POSTGRES_PORT} -U postgres -c "CREATE DATABASE ofp_sandbox;"
- DJANGO_CONFIGURATION="OscarFancypagesPostgres" SANDBOX="oscar_fancypages" ./run-migrations.sh
+ DJANGO_CONFIGURATION="OscarFancypagesPostgres" ./run-migrations.sh
test-oscar-mysql:
- mysql -h 127.0.0.1 -P ${DJANGO_MYSQL_PORT} -u root -e 'DROP DATABASE ofp_sandbox;'
mysql -h 127.0.0.1 -P ${DJANGO_MYSQL_PORT} -u root -e 'CREATE DATABASE ofp_sandbox;'
- DJANGO_CONFIGURATION="OscarFancypagesMysql" SANDBOX="oscar_fancypages" ./run-migrations.sh
+ DJANGO_CONFIGURATION="OscarFancypagesMysql" ./run-migrations.sh
docs:
${MAKE} -C docs html
View
@@ -11,19 +11,17 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
-
import os
import sys
-root_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '../..'))
-
-sandbox_dir = os.path.realpath(
- os.path.join(os.path.dirname(__file__), '../../sandboxes/fancypages'))
+cwd = os.path.dirname(__file__)
+root_dir = os.path.realpath(os.path.join(cwd, '../..'))
+sandbox_dir = os.path.realpath(os.path.join(root_dir, 'sandbox'))
sys.path = [root_dir, sandbox_dir] + sys.path
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
-os.environ.setdefault('DJANGO_CONFIGURATION', 'FancypagesSandbox')
+os.environ.setdefault('DJANGO_CONFIGURATION', 'StandaloneFancypages')
from configurations import importer
importer.install()
@@ -33,14 +31,15 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
-# -- General configuration -----------------------------------------------------
+# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage']
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest',
+ 'sphinx.ext.coverage']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@@ -55,8 +54,8 @@
master_doc = 'index'
# General information about the project.
-project = u'django-fancypages'
-copyright = u'2013, Sebastian Vetter'
+project = 'django-fancypages'
+copyright = '2013, Sebastian Vetter'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -202,8 +201,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
- ('index', 'django-fancypages.tex', u'django-fancypages Documentation',
- u'Sebastian Vetter', 'manual'),
+ ('index', 'django-fancypages.tex', 'django-fancypages Documentation',
+ 'Sebastian Vetter', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -232,8 +231,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
- ('index', 'django-fancypages', u'django-fancypages Documentation',
- [u'Sebastian Vetter'], 1)
+ ('index', 'django-fancypages', 'django-fancypages Documentation',
+ ['Sebastian Vetter'], 1)
]
# If true, show URL addresses after external links.
@@ -246,8 +245,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
- ('index', 'django-fancypages', u'django-fancypages Documentation',
- u'Sebastian Vetter', 'django-fancypages', 'One line description of project.',
+ ('index', 'django-fancypages', 'django-fancypages Documentation',
+ 'Sebastian Vetter', 'django-fancypages', 'One line description of project.',
'Miscellaneous'),
]
@@ -290,14 +289,14 @@ def process_docstring(app, what, name, obj, options, lines):
if help_text:
# Add the model field to the end of the docstring as a param
# using the help text as the description
- lines.append(u':param %s: %s' % (field.attname, help_text))
+ lines.append(':param %s: %s' % (field.attname, help_text))
else:
# Add the model field to the end of the docstring as a param
# using the verbose name as the description
- lines.append(u':param %s: %s' % (field.attname, verbose_name))
+ lines.append(':param %s: %s' % (field.attname, verbose_name))
# Add the field's type to the docstring
- lines.append(u':type %s: %s' % (field.attname, type(field).__name__))
+ lines.append(':type %s: %s' % (field.attname, type(field).__name__))
# Return the extended docstring
return lines
View
@@ -8,7 +8,7 @@ pep8ignore=
conftest.py ALL
tests/* ALL
- sandboxes/* ALL
+ sandbox/* ALL
docs/* ALL
*/migrations/* ALL
View
@@ -1,5 +1,6 @@
# development tools
django-extensions>=0.9
+South==1.0.0
# simplify configurations
django-configurations==0.8
View
@@ -1,15 +1,14 @@
#! /bin/bash
-DJANGO_VERSION=`./sandboxes/fancypages/manage.py --version`
+DJANGO_VERSION=`./sandbox/manage.py --version`
DJANGO_MINOR=${DJANGO_VERSION:2:1}
-SANDBOX=${SANDBOX:-fancypages}
if [ ${DJANGO_MINOR} -lt 7 ];
then
echo "Running South migrations";
- python sandboxes/${SANDBOX}/manage.py syncdb --noinput
- python sandboxes/${SANDBOX}/manage.py migrate
+ python sandbox/manage.py syncdb --noinput
+ python sandbox/manage.py migrate
else
echo "Running Django migrations";
- python sandboxes/${SANDBOX}/manage.py migrate --noinput
+ python sandbox/manage.py migrate --noinput
fi
@@ -26,7 +26,7 @@ class Common(Configuration):
LANGUAGE_CODE = 'en-gb'
LANGUAGES = (
('de', 'German'),
- ('en', 'English'))
+ ('en-gb', 'English'))
########## FANCYPAGES SETTINGS
FP_FORM_BLOCK_CHOICES = {
@@ -36,6 +36,12 @@ def INSTALLED_APPS(self):
FP_PAGE_DETAIL_VIEW = 'fancypages.contrib.oscar_fancypages.views.FancyPageDetailView' # noqa
########## END FANCYPAGES SETTINGS
+ # Required for South < 1.0
+ SOUTH_MIGRATION_MODULES = {
+ 'fancypages': 'fancypages.south_migrations',
+ 'oscar_fancypages': 'fancypages.contrib.oscar_fancypages.south_migrations', # noqa
+ }
+
########## OSCAR SETTINGS
OSCAR_ALLOW_ANON_CHECKOUT = True
View
@@ -21,7 +21,6 @@
include_package_data=True,
install_requires=[
'Django>=1.5',
- 'South',
'unidecode',
'django-treebeard',
'django-model-utils',
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals, absolute_import
import os
import tempfile
@@ -54,6 +56,8 @@ def test_update_a_toplevel_page(self):
page_description = "The old description"
now = timezone.now()
+ current_tz = timezone.get_current_timezone()
+
fancy_page = factories.FancyPageFactory(
date_visible_start=now, node__name=page_name,
node__description=page_description)
@@ -69,8 +73,7 @@ def test_update_a_toplevel_page(self):
self.assertEquals(form['description'].value.strip(), page_description)
self.assertEquals(
form['date_visible_start'].value,
- date(now, 'Y-m-d H:i:s')
- )
+ date(now.astimezone(current_tz), 'Y-m-d H:i:s'))
form['name'] = 'Another name'
form['description'] = "Some description"
View
@@ -4,18 +4,22 @@
import sys
from sandbox import settings
+from sandbox.settings import common
from fancypages.test import TEMP_MEDIA_ROOT
sys.path.insert(0, os.path.join(os.path.dirname(settings.__file__), '..'))
class TestSettingsMixin(object):
MEDIA_ROOT = TEMP_MEDIA_ROOT
+ DATABASES = {'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': ':memory:'}}
class StandaloneTest(TestSettingsMixin, settings.StandaloneFancypages):
pass
class OscarTest(TestSettingsMixin, settings.OscarFancypages):
- pass
+ TEMPLATE_CONTEXT_PROCESSORS = common.Common.TEMPLATE_CONTEXT_PROCESSORS
@@ -60,6 +60,7 @@ def test_passing_valid_url_or_lookup_returns_valid_url(url, expected,
def test_form_settings_can_be_iterated_as_choices(settings):
+ settings.FP_FORM_BLOCK_CHOICES = {}
config = BlockFormSettings()
config.update({'default': {'name': 'The Default'}})
config.update({'test': {'name': 'Another form'}})
@@ -1,6 +1,7 @@
-import mock
-
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals, absolute_import
from django.test import TestCase
+from django.test import RequestFactory
from django.template import RequestContext
from fancypages.models import Container
@@ -14,9 +15,8 @@ class TestTwoColumnLayoutBlock(TestCase):
def setUp(self):
super(TestTwoColumnLayoutBlock, self).setUp()
self.user = factories.UserFactory.build()
- self.request = mock.Mock()
- self.request.META = {}
+ self.request = RequestFactory().get('/')
self.request_context = RequestContext(self.request, {})
self.request_context['user'] = self.user
@@ -1,55 +1,54 @@
-import mock
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals, absolute_import
+import pytest
-from django.test import TestCase
from django.template import RequestContext
+from django.test import RequestFactory
from django.contrib.auth.models import User
from fancypages.test import factories
from fancypages.models import Container
from fancypages.renderers import ContainerRenderer
-class TestAContainer(TestCase):
+@pytest.fixture
+def request_context():
+ request = RequestFactory().get('/')
+ request.fp_edit_mode = True
+ request.user = User()
+ return RequestContext(request, {})
- def setUp(self):
- super(TestAContainer, self).setUp()
- self.request = mock.Mock()
- self.request.META = {}
- self.request_context = RequestContext(self.request, {})
- def test_can_be_retrieved_by_name(self):
- container = Container.objects.create(name='some-container')
- retrieved_container = Container.get_container_by_name(container.name)
- self.assertEquals(container.id, retrieved_container.id)
+def test_container_can_be_retrieved_by_name(request_context, db):
+ container = Container.objects.create(name='some-container')
+ retrieved_container = Container.get_container_by_name(container.name)
+ assert container.id == retrieved_container.id
- def test_renders_block_selection_correctly(self):
- self.request.fp_edit_mode = True
- ctn_id = 15
- container = factories.ContainerFactory.build(id=ctn_id)
- html = ContainerRenderer(container, self.request_context).render()
- self.assertIn(
- 'data-target="#block_selection_modal"'.format(container.uuid),
- html)
- self.assertIn('data-container-id="{}"'.format(container.uuid), html)
+def test_renders_block_selection_correctly(request_context, db):
+ ctn_id = 15
+ container = factories.ContainerFactory.build(id=ctn_id)
+ html = ContainerRenderer(container, request_context).render()
- def test_generates_a_name_based_on_specified_uuid(self):
- container = Container.objects.create(uuid='fakeuuid')
- self.assertEqual(container.name, "container-fakeuuid")
+ assert 'data-target="#block_selection_modal"'.format(container.uuid) in html # noqa
+ assert 'data-container-id="{}"'.format(container.uuid) in html
- def test_generates_a_name_based_on_autogenerated_uuid(self):
- container = Container.objects.create(uuid='fakeuuid')
- self.assertNotEqual(container.uuid, None)
- self.assertEqual(container.name, "container-{}".format(container.uuid))
+def test_container_generates_a_name_based_on_specified_uuid(db):
+ container = Container.objects.create(uuid='fakeuuid')
+ assert container.name == "container-fakeuuid"
-class TestAnObjectContainer(TestCase):
- def test_can_be_retrieved_by_name(self):
- user = User.objects.create(username='testuser')
- container = Container.objects.create(
- name='some-container', page_object=user)
+def test_container_generates_a_name_based_on_autogenerated_uuid(db):
+ container = Container.objects.create()
+ assert container.uuid is not None
+ assert container.name == "container-{}".format(container.uuid)
- retrieved_container = Container.get_container_by_name(
- container.name, user)
- self.assertEquals(container.id, retrieved_container.id)
+
+def test_object_container_can_be_retrieved_by_name(db):
+ user = User.objects.create(username='testuser')
+ container = Container.objects.create(
+ name='some-container', page_object=user)
+
+ retrieved_container = Container.get_container_by_name(container.name, user)
+ assert container.id == retrieved_container.id
Oops, something went wrong.

0 comments on commit edadcdf

Please sign in to comment.