diff --git a/.travis.yml b/.travis.yml index 716cd37..450f153 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ language: python python: + - 3.4 - 3.3 - 2.7 - 2.6 @@ -12,7 +13,6 @@ install: - pip install -r requirements.txt - pip install coveralls coverage - "if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi" - - "if [[ $TRAVIS_PYTHON_VERSION == '3.3' ]]; then pip install -U https://github.com/pypa/pip/archive/develop.zip; fi" # command to run tests, e.g. python setup.py test script: USE_SHM="yes" coverage run setup.py test @@ -22,3 +22,4 @@ after_success: coveralls matrix: allow_failures: - python: 3.3 + - python: 3.4 diff --git a/AUTHORS.rst b/AUTHORS.rst index 732b8f9..e6addf7 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -12,9 +12,12 @@ Development Lead Contributors ------------ -* Carlo Ascani * Aaron Boman -* Henning Sprang -* Nick Moore +* Carlo Ascani +* Claudio Luck * Enkel Mitrushi +* growlf +* Henning Sprang * Jonas Obrist +* Nick Moore +* pipsqueaker \ No newline at end of file diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 44667e9..64f7a15 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -67,7 +67,7 @@ Ready to contribute? Here's how to set up `djangocms-installer` for local develo $ mkvirtualenv djangocms-installer $ cd djangocms-installer/ $ python setup.py develop - $ pip install requirements_dev.txt + $ pip install -r requirements_dev.txt the last one is to get the requirements including testing and development tools installed. @@ -82,7 +82,7 @@ Now you can make your changes locally. tests, including testing other Python versions with tox:: $ flake8 djangocms-installer tests - $ python setup.py test + $ python setup.py test $ tox 6. Commit your changes and push your branch to GitHub:: diff --git a/HISTORY.rst b/HISTORY.rst index 58dd0a4..159086f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,11 +3,20 @@ History ------- +0.6.0 (2014-11-30) +++++++++++++++++++ + +* Add support for installing aldryn-boilerplate +* Force installing all packages (-I) when creating the project virtualenv +* Fix multiplatform support bugs +* Update supported Django / django CMS versions +* Add preliminary support for django CMS develop (3.1) + 0.5.4 (2014-08-14) ++++++++++++++++++ * Fix reversion version selection for older Django versions -* Berter project name validation +* Better project name validation 0.5.3 (2014-07-23) ++++++++++++++++++ diff --git a/README.rst b/README.rst index 8d18b45..39dcafa 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,25 @@ Documentation See http://djangocms-installer.readthedocs.org +Supported versions +------------------ + +The current supported version matrix is the following: + ++----------------+-------------+-------------+-------------+-------------+ +| | Django 1.4 | Django 1.5 | Django 1.6 | Django 1.7 | ++----------------+-------------+-------------+-------------+-------------+ +| django CMS 2.4 | Supported | Supported | Unsupported | Unsupported | ++----------------+-------------+-------------+-------------+-------------+ +| django CMS 3.0 | Supported | Supported | Supported | WiP | ++----------------+-------------+-------------+-------------+-------------+ + +Any beta and develop version of Django and django CMS, by its very nature, +it's not supported, while it still may work. + +``djangocms-installer`` tries to support beta versions of django CMS when they +will be considered sufficiently stable by the upstream project. + Caveats ------- @@ -64,6 +83,7 @@ Libraries you would want to check: * zlib (for PNG support in ``Pillow``) * postgresql (for ``psycopg``) * libmysqlclient (for ``Mysql-Python``) +* python-dev (for compilation and linking) For additional information, check http://djangocms-installer.readthedocs.org/en/latest/libraries.html diff --git a/djangocms_installer/__init__.py b/djangocms_installer/__init__.py index 1a1a4c1..add1b3d 100644 --- a/djangocms_installer/__init__.py +++ b/djangocms_installer/__init__.py @@ -2,4 +2,4 @@ # -*- coding: utf-8 -*- __author__ = 'Iacopo Spalletti' __email__ = 'i.spalletti@nephila.it' -__version__ = '0.5.4' +__version__ = '0.6.b1' diff --git a/djangocms_installer/__main__.py b/djangocms_installer/__main__.py index d294f64..59d513e 100644 --- a/djangocms_installer/__main__.py +++ b/djangocms_installer/__main__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import sys + from .main import execute if __name__ == '__main__': diff --git a/djangocms_installer/config/__init__.py b/djangocms_installer/config/__init__.py index 07d5a2a..db66e73 100644 --- a/djangocms_installer/config/__init__.py +++ b/djangocms_installer/config/__init__.py @@ -4,11 +4,12 @@ import os.path import six import sys +import warnings -from .. import compat, utils from . import data -from djangocms_installer.config.internal import DbAction, validate_project -from djangocms_installer.utils import less_than_version, supported_versions +from .internal import DbAction, validate_project +from .. import compat, utils +from ..utils import less_than_version, supported_versions def parse(args): @@ -38,10 +39,10 @@ def parse(args): help='Languages to enable. Option can be provided multiple times, or as a comma separated list. ' 'Only language codes supported by Django can be used here') parser.add_argument('--django-version', dest='django_version', action='store', - choices=('1.4', '1.5', '1.6', 'stable'), + choices=data.DJANGO_SUPPORTED, default='stable', help='Django version') parser.add_argument('--cms-version', '-v', dest='cms_version', action='store', - choices=('2.4', '3.0', 'stable', 'develop'), + choices=data.DJANGOCMS_SUPPORTED, default='stable', help='django CMS version') parser.add_argument('--parent-dir', '-p', dest='project_directory', required=True, default='', @@ -68,6 +69,8 @@ def parse(args): # Advanced options. These have a predefined default and are not managed # by config wizard. + parser.add_argument('--aldryn', '-a', dest='aldryn', action='store_true', + default=False, help="Use Aldryn-boilerplate as project template") parser.add_argument('--no-input', '-q', dest='noinput', action='store_true', default=False, help="Don't run the configuration wizard, just use the provided values") parser.add_argument('--filer', '-f', dest='filer', action='store_true', @@ -83,7 +86,7 @@ def parse(args): parser.add_argument('--no-user', '-u', dest='no_user', action='store_true', default=False, help="Don't create the admin user") parser.add_argument('--template', dest='template', action='store', - default=None, help="The path or URL to load the template from") + default=None, help="The path or URL to load the django project template from.") parser.add_argument('--extra-settings', dest='extra_settings', action='store', default=None, help="The path to an file that contains extra settings.") @@ -158,6 +161,12 @@ def parse(args): # Convert version to numeric format for easier checking django_version, cms_version = supported_versions(args.django_version, args.cms_version) + if django_version is None: + sys.stderr.write("Please provide a Django supported version: %s. Only Major.Minor version selector is accepted\n" % ", ".join(data.DJANGO_SUPPORTED)) + sys.exit(6) + if django_version is None: + sys.stderr.write("Please provide a django CMS supported version: %s. Only Major.Minor version selector is accepted\n" % ", ".join(data.DJANGOCMS_SUPPORTED)) + sys.exit(6) if not getattr(args, 'requirements_file'): requirements = [] @@ -165,17 +174,22 @@ def parse(args): # Django cms version check if args.cms_version == 'develop': requirements.append(data.DJANGOCMS_DEVELOP) + warnings.warn(data.VERSION_WARNING % ('develop', 'django CMS')) elif args.cms_version == 'rc': requirements.append(data.DJANGOCMS_RC) elif args.cms_version == 'beta': requirements.append(data.DJANGOCMS_BETA) + warnings.warn(data.VERSION_WARNING % ('beta', 'django CMS')) else: if args.cms_version == 'stable': requirements.append("django-cms<%s" % less_than_version(data.DJANGOCMS_LATEST)) else: requirements.append("django-cms<%s" % less_than_version(args.cms_version)) - if cms_version >= 3: + + if cms_version == 3: requirements.append(data.DJANGOCMS_3_REQUIREMENTS) + elif cms_version >= 3: + requirements.append(data.DJANGOCMS_3_1_REQUIREMENTS) else: requirements.append(data.DJANGOCMS_2_REQUIREMENTS) @@ -183,17 +197,31 @@ def parse(args): requirements.append(args.db_driver) if args.filer: if cms_version >= 3: - requirements.append(data.FILER_REQUIREMENTS_CMS3) + if django_version < 1.7: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC) + requirements.append(data.FILER_REQUIREMENTS_CMS3) + else: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC_DJANGO_17) + requirements.append(data.FILER_REQUIREMENTS_CMS3) else: requirements.append(data.FILER_REQUIREMENTS_CMS2) elif cms_version >= 3: - requirements.append(data.PLUGIN_REQUIREMENTS) + if django_version < 1.7: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC) + requirements.append(data.PLUGINS_REQUIREMENTS_NON_FILER) + else: + requirements.append(data.PLUGINS_REQUIREMENTS_BASIC_DJANGO_17) + requirements.append(data.PLUGINS_REQUIREMENTS_NON_FILER_DJANGO_17) + if args.aldryn: + requirements.append(data.ALDRYN_REQUIREMENTS) # Django version check if args.django_version == 'develop': requirements.append(data.DJANGO_DEVELOP) + warnings.warn(data.VERSION_WARNING % ('develop', 'Django')) elif args.django_version == 'beta': requirements.append(data.DJANGO_BETA) + warnings.warn(data.VERSION_WARNING % ('beta', 'Django')) else: if args.django_version == 'stable': if cms_version < 3: @@ -201,24 +229,33 @@ def parse(args): else: requirements.append("Django<%s" % less_than_version(data.DJANGO_LATEST_CMS_3)) else: - requirements.append("Django<%s" % less_than_version(args.django_version)) + requirements.append("Django<%s" % less_than_version(str(django_version))) # Timezone support if args.use_timezone: requirements.append('pytz') + # Requirements dependendent on django version + if django_version < 1.7: + requirements.append(data.DJANGO_16_REQUIREMENTS) + # Reversion package version depends on django version if args.reversion: if django_version < 1.5: requirements.append(data.DJANGO_14_REVERSION) elif django_version == 1.5: requirements.append(data.DJANGO_15_REVERSION) - else: + elif django_version == 1.6: requirements.append(data.DJANGO_16_REVERSION) + else: + requirements.append(data.DJANGO_17_REVERSION) requirements.extend([data.DEFAULT_REQUIREMENTS]) setattr(args, "requirements", "\n".join(requirements).strip()) + if cms_version < 3 and args.aldryn: + sys.stderr.write("Aldryn Boilerplate is not compatible with django CMS versions < 3\n") + sys.exit(5) # Convenient shortcuts setattr(args, "cms_version", cms_version) diff --git a/djangocms_installer/config/data.py b/djangocms_installer/config/data.py index 769f45c..cf5802f 100644 --- a/djangocms_installer/config/data.py +++ b/djangocms_installer/config/data.py @@ -8,38 +8,50 @@ DJANGOCMS_RC = 'https://github.com/divio/django-cms/archive/3.0c2.zip' DJANGOCMS_BETA = 'https://github.com/divio/django-cms/archive/3.0.0.beta3.zip' DJANGOCMS_LATEST = '3.0' +DJANGOCMS_SUPPORTED = ('2.4', '3.0', 'stable', 'develop') DJANGO_DEVELOP = 'https://github.com/django/django/archive/master.zip' # this is not true, but it's the most recent version # compatible with all the CMS versions DJANGO_LATEST = '1.5' DJANGO_LATEST_CMS_3 = '1.6' +DJANGO_SUPPORTED = ('1.4', '1.5', '1.6', '1.7', 'stable') + DEFAULT_REQUIREMENTS = """ django-classy-tags>=0.3.4.1 -south>=0.7.2 html5lib Pillow>=2 django-sekizai>=0.7 six """ +DJANGO_16_REQUIREMENTS = """ +south>=0.7.2 +""" + DJANGOCMS_2_REQUIREMENTS = """ django-mptt>=0.5.1,<0.5.3 """ DJANGOCMS_3_REQUIREMENTS = """ django-mptt>=0.6 -djangocms-text-ckeditor>=2.1.4 +""" +DJANGOCMS_3_1_REQUIREMENTS = """ +django-treebeard==2.0 +""" + +PLUGINS_REQUIREMENTS_BASIC = """ djangocms-admin-style djangocms-column -djangocms-style djangocms-flash djangocms-googlemap djangocms-inherit +djangocms-style +djangocms-text-ckeditor>=2.3.0 """ -PLUGIN_REQUIREMENTS = """ +PLUGINS_REQUIREMENTS_NON_FILER = """ djangocms-file djangocms-link djangocms-picture @@ -47,6 +59,29 @@ djangocms-video """ +PLUGINS_REQUIREMENTS_BASIC_DJANGO_17 = """ +https://github.com/divio/djangocms-admin-style/archive/master.zip +https://github.com/divio/djangocms-column/archive/master.zip +https://github.com/divio/djangocms-flash/archive/master.zip +https://github.com/divio/djangocms-googlemap/archive/master.zip +https://github.com/divio/djangocms-inherit/archive/master.zip +https://github.com/divio/djangocms-style/archive/master.zip +https://github.com/divio/djangocms-text-ckeditor/archive/master.zip +""" + +PLUGINS_REQUIREMENTS_NON_FILER_DJANGO_17 = """ +https://github.com/divio/djangocms-file/archive/master.zip +https://github.com/divio/djangocms-link/archive/master.zip +https://github.com/divio/djangocms-picture/archive/master.zip +https://github.com/divio/djangocms-teaser/archive/master.zip +https://github.com/divio/djangocms-video/archive/master.zip +""" + + +DJANGO_17_REVERSION = "django-reversion>=1.8.2" +ALDRYN_REQUIREMENTS = """ +django-compressor +""" DJANGO_16_REVERSION = "django-reversion>=1.8" DJANGO_15_REVERSION = "django-reversion>=1.7,<1.8" DJANGO_14_REVERSION = "django-reversion<1.7" @@ -64,17 +99,17 @@ PLUGIN_LIST_TEXT = """ djangocms_installer will install and configure the following plugins: - * djangocms-text-ckeditor (Text plugin) + * djangocms_column (Column plugin) * djangocms-file (File plugin) * djangocms-flash (Flash plugin) * djangocms-googlemap (GoogleMap plugin) * djangocms-inherit (Inherit plugin) * djangocms-link (Link plugin) * djangocms-picture (Picture plugin) + * djangocms_style (Style plugin) * djangocms-teaser (Teaser plugin) + * djangocms-text-ckeditor (Text plugin) * djangocms-video (Video plugin) - * djangocms_style (Style plugin) - * djangocms_column (Style plugin) It will optionally install cmsplugin-filer plugins (if requested during configuration): @@ -106,3 +141,7 @@ BASE_DIR = """ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) """ + +ALDRYN_BOILERPLATE = 'https://github.com/aldryn/aldryn-boilerplate/archive/master.zip' + +VERSION_WARNING = '%s version of %s is not supported and it may not work as expected' diff --git a/djangocms_installer/config/internal.py b/djangocms_installer/config/internal.py index ad14490..5151504 100644 --- a/djangocms_installer/config/internal.py +++ b/djangocms_installer/config/internal.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import sys +from argparse import Action import keyword +import sys -from argparse import Action import dj_database_url from .data import DRIVERS diff --git a/djangocms_installer/config/settings.py b/djangocms_installer/config/settings.py index b7458cf..4614277 100644 --- a/djangocms_installer/config/settings.py +++ b/djangocms_installer/config/settings.py @@ -59,7 +59,6 @@ 'cms', 'mptt', 'menus', - 'south', 'sekizai', ) @@ -133,6 +132,13 @@ REVERSION_APPLICATIONS = ( 'reversion', ) +SOUTH_APPLICATIONS = ( + 'south', +) + +ALDRYN_APPLICATIONS = ( + 'compressor', +) CMS_TEMPLATES = ( ('fullwidth.html', 'Fullwidth'), @@ -174,3 +180,19 @@ SOUTH_MIGRATION_MODULES = ( ('easy_thumbnails', 'easy_thumbnails.south_migrations'), ) + +MIGRATION_MODULES = ( + ('cms', 'cms.migrations_django'), + ('menus', 'menus.migrations_django'), + ('djangocms_text_ckeditor', 'djangocms_text_ckeditor.migrations_django'), + ('djangocms_column', 'djangocms_column.migrations_django'), + ('djangocms_file', 'djangocms_file.migrations_django'), + ('djangocms_flash', 'djangocms_flash.migrations_django'), + ('djangocms_googlemap', 'djangocms_googlemap.migrations_django'), + ('djangocms_inherit', 'djangocms_inherit.migrations_django'), + ('djangocms_link', 'djangocms_link.migrations_django'), + ('djangocms_picture', 'djangocms_picture.migrations_django'), + ('djangocms_style', 'djangocms_style.migrations_django'), + ('djangocms_teaser', 'djangocms_teaser.migrations_django'), + ('djangocms_video', 'djangocms_video.migrations_django'), +) \ No newline at end of file diff --git a/djangocms_installer/config/urls.py b/djangocms_installer/config/urls.py index d020847..c456ce1 100644 --- a/djangocms_installer/config/urls.py +++ b/djangocms_installer/config/urls.py @@ -1,9 +1,9 @@ +from cms.sitemaps import CMSSitemap from django.conf.urls import * # NOQA from django.conf.urls.i18n import i18n_patterns from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.contrib import admin from django.conf import settings -from cms.sitemaps import CMSSitemap admin.autodiscover() diff --git a/djangocms_installer/django/__init__.py b/djangocms_installer/django/__init__.py index 59f9b5b..0f69f1f 100644 --- a/djangocms_installer/django/__init__.py +++ b/djangocms_installer/django/__init__.py @@ -1,12 +1,20 @@ # -*- coding: utf-8 -*- -import sys +from copy import copy, deepcopy +import glob import os import re - +import requests +try: + from shlex import quote as shlex_quote +except ImportError: + from pipes import quote as shlex_quote import shutil -import glob import subprocess -from copy import copy, deepcopy +import sys +import tempfile +import zipfile +from six import BytesIO + from ..compat import iteritems from ..utils import chdir @@ -40,21 +48,43 @@ def copy_files(config_data): urlconf_path = os.path.join(os.path.dirname(__file__), '../config/urls.py') share_path = os.path.join(os.path.dirname(__file__), '../share') template_path = os.path.join(share_path, 'templates') - template_target = os.path.join(config_data.project_path, 'templates') - static_project = os.path.join(config_data.project_directory, 'static') - static_main = os.path.join(config_data.project_path, 'static') - - if config_data.templates and os.path.isdir(config_data.templates): - template_path = config_data.templates - elif config_data.bootstrap: - template_path = os.path.join(template_path, 'bootstrap') + if config_data.aldryn: + media_project = os.path.join(config_data.project_directory, 'dist', 'media') + static_main = False + static_project = os.path.join(config_data.project_directory, 'dist', 'static') + template_target = os.path.join(config_data.project_directory, 'templates') + tmpdir = tempfile.mkdtemp() + aldrynzip = requests.get(data.ALDRYN_BOILERPLATE) + zip_open = zipfile.ZipFile(BytesIO(aldrynzip.content)) + zip_open.extractall(path=tmpdir) + for component in os.listdir(os.path.join(tmpdir, 'aldryn-boilerplate-master')): + src = os.path.join(tmpdir, 'aldryn-boilerplate-master', component) + dst = os.path.join(config_data.project_directory, component) + if os.path.isfile(src): + shutil.copy(src, dst) + else: + shutil.copytree(src, dst) else: - template_path = os.path.join(template_path, 'basic') + media_project = os.path.join(config_data.project_directory, 'media') + static_main = os.path.join(config_data.project_path, 'static') + static_project = os.path.join(config_data.project_directory, 'static') + template_target = os.path.join(config_data.project_path, 'templates') + if config_data.templates and os.path.isdir(config_data.templates): + template_path = config_data.templates + elif config_data.bootstrap: + template_path = os.path.join(template_path, 'bootstrap') + else: + template_path = os.path.join(template_path, 'basic') shutil.copy(urlconf_path, config_data.urlconf_path) - os.makedirs(static_main) - os.makedirs(static_project) - os.makedirs(template_target) + if media_project: + os.makedirs(media_project) + if static_main: + os.makedirs(static_main) + if not os.path.exists(static_project): + os.makedirs(static_project) + if not os.path.exists(template_target): + os.makedirs(template_target) for filename in glob.glob(os.path.join(template_path, '*.html')): if os.path.isfile(filename): shutil.copy(filename, template_target) @@ -89,34 +119,41 @@ def patch_settings(config_data): original = original.replace("# -*- coding: utf-8 -*-\n", "") + if config_data.aldryn: + DATA_DIR = "DATA_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'dist')\n" + STATICFILES_DIR = 'os.path.join(BASE_DIR, \'static\'),' + else: + DATA_DIR = "DATA_DIR = os.path.dirname(os.path.dirname(__file__))\n" + STATICFILES_DIR = 'os.path.join(BASE_DIR, \'%s\', \'static\'),' % config_data.project_name + if original.find('BASE_DIR') == -1: - original = data.DEFAULT_PROJECT_HEADER + data.BASE_DIR + original + original = data.DEFAULT_PROJECT_HEADER + data.BASE_DIR + DATA_DIR + original else: - original = data.DEFAULT_PROJECT_HEADER + original + original = data.DEFAULT_PROJECT_HEADER + DATA_DIR + original if original.find('MEDIA_URL') > -1: original = original.replace("MEDIA_URL = ''", "MEDIA_URL = '/media/'") else: original += "MEDIA_URL = '/media/'\n" if original.find('MEDIA_ROOT') > -1: - original = original.replace("MEDIA_ROOT = ''", "MEDIA_ROOT = os.path.join(BASE_DIR, 'media')") + original = original.replace("MEDIA_ROOT = ''", "MEDIA_ROOT = os.path.join(DATA_DIR, 'media')") else: - original += "MEDIA_ROOT = os.path.join(BASE_DIR, 'media')\n" + original += "MEDIA_ROOT = os.path.join(DATA_DIR, 'media')\n" if original.find('STATIC_ROOT') > -1: - original = original.replace("STATIC_ROOT = ''", "STATIC_ROOT = os.path.join(BASE_DIR, 'static')") + original = original.replace("STATIC_ROOT = ''", "STATIC_ROOT = os.path.join(DATA_DIR, 'static')") else: - original += "STATIC_ROOT = os.path.join(BASE_DIR, 'static')\n" + original += "STATIC_ROOT = os.path.join(DATA_DIR, 'static')\n" if original.find('STATICFILES_DIRS') > -1: original = original.replace(data.STATICFILES_DEFAULT, """ STATICFILES_DIRS = ( - os.path.join(BASE_DIR, '%s', 'static'), + %s ) -""" % config_data.project_name) +""" % STATICFILES_DIR) else: original += """ STATICFILES_DIRS = ( - os.path.join(BASE_DIR, '%s', 'static'), + %s ) -""" % config_data.project_name +""" % STATICFILES_DIR original = original.replace("# -*- coding: utf-8 -*-\n", "") # I18N @@ -177,8 +214,12 @@ def _build_settings(config_data): text.append("TEMPLATE_CONTEXT_PROCESSORS = (\n%s%s\n)" % ( spacer, (",\n" + spacer).join(["'%s'" % var for var in processors]))) - text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( - spacer, "os.path.join(BASE_DIR, '%s', 'templates')," % config_data.project_name)) + if config_data.aldryn: + text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( + spacer, "os.path.join(BASE_DIR, 'templates'),")) + else: + text.append("TEMPLATE_DIRS = (\n%s%s\n)" % ( + spacer, "os.path.join(BASE_DIR, '%s', 'templates')," % config_data.project_name)) apps = list(vars.INSTALLED_APPS) if config_data.cms_version == 2.4: @@ -197,6 +238,11 @@ def _build_settings(config_data): apps.extend(vars.FILER_PLUGINS_3) else: apps.extend(vars.STANDARD_PLUGINS_3) + if config_data.django_version <= 1.6: + apps.extend(vars.SOUTH_APPLICATIONS) + + if config_data.aldryn: + apps.extend(vars.ALDRYN_APPLICATIONS) if config_data.reversion: apps.extend(vars.REVERSION_APPLICATIONS) text.append("INSTALLED_APPS = (\n%s%s\n)" % ( @@ -250,11 +296,16 @@ def _build_settings(config_data): text.append("DATABASES = {\n%s'default':\n%s%s\n}" % (spacer, spacer * 2, config_data.db_parsed)) + if config_data.django_version >= 1.7: + text.append("MIGRATION_MODULES = {\n%s%s\n}" % ( + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.MIGRATION_MODULES]))) + if config_data.filer: text.append("THUMBNAIL_PROCESSORS = (\n%s%s\n)" % ( spacer, (",\n" + spacer).join(["'%s'" % var for var in vars.THUMBNAIL_PROCESSORS]))) - text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( - spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.SOUTH_MIGRATION_MODULES]))) + if config_data.django_version <= 1.6: + text.append("SOUTH_MIGRATION_MODULES = {\n%s%s\n}" % ( + spacer, (",\n" + spacer).join(["'%s': '%s'" % item for item in vars.SOUTH_MIGRATION_MODULES]))) return "\n\n".join(text) @@ -262,20 +313,27 @@ def setup_database(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) - try: - import south # NOQA - subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--all", "--noinput"]) - subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "migrate", "--fake"]) - except ImportError: + env = dict(os.environ) + env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path)) + + if config_data.django_version < 1.7: + try: + import south # NOQA + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "syncdb", "--all", "--noinput"], env=env) + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "migrate", "--fake"], env=env) + except ImportError: + subprocess.check_call([sys.executable, "-W", "ignore", + "manage.py", "syncdb", "--noinput"], env=env) + print("south not installed, migrations skipped") + else: subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "syncdb", "--noinput"]) - print("south not installed, migrations skipped") + "manage.py", "migrate", "--noinput"], env=env) if not config_data.no_user and not config_data.noinput: print("\n\nCreating admin user") subprocess.check_call([sys.executable, "-W", "ignore", - "manage.py", "createsuperuser"]) + "manage.py", "createsuperuser"], env=env) def load_starting_page(config_data): @@ -285,7 +343,9 @@ def load_starting_page(config_data): with chdir(config_data.project_directory): os.environ['DJANGO_SETTINGS_MODULE'] = ( '{0}.settings'.format(config_data.project_name)) - subprocess.check_call([sys.executable, "starting_page.py"]) + env = dict(os.environ) + env['PYTHONPATH'] = os.pathsep.join(map(shlex_quote, sys.path)) + subprocess.check_call([sys.executable, "starting_page.py"], env=env) for ext in ['py', 'pyc', 'json']: try: os.remove('starting_page.%s' % ext) diff --git a/djangocms_installer/install/__init__.py b/djangocms_installer/install/__init__.py index 551f901..74f0983 100644 --- a/djangocms_installer/install/__init__.py +++ b/djangocms_installer/install/__init__.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import os.path - import pip from pip.exceptions import InstallationError from pip.status_codes import SUCCESS @@ -55,11 +54,18 @@ def check_install(config_data): def requirements(requirements, is_file=False): if is_file: - args = ['install', '-q', '-r', requirements] + args = ['install', '-q', '-I', '-r', requirements] else: - args = ['install', '-q', ] + args = ['install', '-q', '-I'] args.extend(requirements.split()) exit_status = pip.main(args) if exit_status != SUCCESS: raise InstallationError("Error while installing requirements. Check pip log file for error details.") return True + + +def cleanup(requirements): + args = ['uninstall', '-q', '-y'] + args.extend(requirements.split()) + exit_status = pip.main(args) + return True diff --git a/djangocms_installer/main.py b/djangocms_installer/main.py index 1b73463..07b57a7 100644 --- a/djangocms_installer/main.py +++ b/djangocms_installer/main.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -import sys -import six import logging +import six +import sys from . import config, install, django @@ -31,9 +31,14 @@ def execute(): django.setup_database(config_data) if config_data.starting_page: django.load_starting_page(config_data) - print("All done!") - print("Get into '%s' directory and type 'python manage.py runserver' " - "to start your project" % config_data.project_directory) + if config_data.aldryn: + print("Project created!") + print("aldryn boilerplate requires action before you can actually run the project.\n" + "See documentation at http://aldryn-boilerplate.readthedocs.org/ for more information.") + else: + print("All done!") + print("Get into '%s' directory and type 'python manage.py runserver' " + "to start your project" % config_data.project_directory) except Exception as e: if six.PY3: tb = sys.exc_info()[2] diff --git a/djangocms_installer/utils.py b/djangocms_installer/utils.py index 4086920..381e0ff 100644 --- a/djangocms_installer/utils.py +++ b/djangocms_installer/utils.py @@ -46,32 +46,33 @@ def supported_versions(django, cms): """ Convert numeric and literal version information to numeric format """ - cms_version = 3 - django_version = 1.5 + cms_version = None + django_version = None try: cms_version = float(cms) except ValueError: if cms == 'stable': cms_version = 3.0 - elif django == 'rc': - django_version = 3.0 - elif django == 'beta': - django_version = 3.0 - elif django == 'develop': - django_version = 3.0 + elif cms == 'rc': + cms_version = 3.1 + elif cms == 'beta': + cms_version = 3.1 + elif cms == 'develop': + cms_version = 3.1 try: django_version = float(django) except ValueError: if django == 'stable': - if cms_version == 3.0: - django_version = 1.6 - else: - django_version = 1.5 + if cms_version: + if cms_version >= 3.0: + django_version = 1.6 + else: + django_version = 1.5 elif django == 'beta': - django_version = 1.6 + django_version = 1.8 elif django == 'develop': - django_version = 1.7 + django_version = 1.8 return django_version, cms_version diff --git a/docs/faq.rst b/docs/faq.rst index abc928e..fdfebc8 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -27,6 +27,16 @@ FAQ **djangocms-installer** uses `dj-database-url`_ to get database configuration parameters; refer to this package for more details. +#. The installer dies with an error like ``ImportError: Could not import settings 'foo.bar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named foo.bar.settings``, + what's happening? + + Chances are you have ``DJANGO_SETTINGS_MODULE`` set in you environment, + either by default or using postactivate virtualenv hooks or other tools; + please check you environment right after the error happening (for example + using the ``env`` command on *nix systems) and remove any customisation: the + installer requires that ``DJANGO_SETTINGS_MODULE`` is not set on the first + run. You can customise it later. + .. _dj-database-url: https://github.com/kennethreitz/dj-database-url .. _project: https://github.com/nephila/djangocms-installer/issues diff --git a/docs/reference.rst b/docs/reference.rst index a670603..4aba97f 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -63,7 +63,12 @@ advanced usage: project; * ``--extra-settings``: Path to a file with extra variables to append to generated settings file. It doesn't need to be a Python file, its content is blindly copied in the project settings. - +*``--aldryn``, ``-a``: Use `aldryn-boilerplate`_; this downloads **aldryn-boilerplate** and copies it + into the project, adapting the project layout according to boilerplate specifications; the use + of aldryn-boilerplate requires manual actions, look at `aldryn-boilerplate documentation`_ for + further informations. .. _dj-database-url: https://github.com/kennethreitz/dj-database-url .. _django source: https://github.com/django/django/blob/master/django/conf/global_settings.py#L50 +.. _aldryn-boilerplate: https://github.com/aldryn/aldryn-boilerplate +.. _aldryn-boilerplate documentation: http://aldryn-boilerplate.readthedocs.org/en/latest/general/requirements.html \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index d0d11ec..7311de6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ dj-database-url pip>1.4 six argparse +requests diff --git a/setup.py b/setup.py index 558eb94..3552c91 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,7 @@ if sys.version_info[:2] < (2, 7): test_requirements.append('unittest2') + setup( name='djangocms-installer', version=djangocms_installer.__version__, @@ -42,7 +43,7 @@ zip_safe=False, keywords='djangocms-installer', classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production', 'Framework :: Django', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', @@ -52,6 +53,7 @@ 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', 'Topic :: Software Development', ], test_suite='tests', diff --git a/tests/__init__.py b/tests/__init__.py index a9473b0..7c68785 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,45 +1 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -import sys -import os -import tempfile -import shutil - -if sys.version_info[:2] < (2, 7): - import unittest2 as unittest -else: - import unittest - -from six import StringIO - - -class BaseTestClass(unittest.TestCase): - stdout = None - stderr = None - project_dir = None - - def _remove_project_dir(self): - if self.project_dir: - shutil.rmtree(self.project_dir) - self.project_dir = None - - def _create_project_dir(self): - if 'USE_SHM' in os.environ: - if os.path.exists('/run/shm'): - self.project_dir = tempfile.mkdtemp(dir='/run/shm') - elif os.path.exists('/dev/shm'): - self.project_dir = tempfile.mkdtemp(dir='/dev/shm') - else: - self.project_dir = tempfile.mkdtemp() - else: - self.project_dir = tempfile.mkdtemp() - - def tearDown(self): - self._remove_project_dir() - self.stdout = None - self.stderr = None - - def setUp(self): - self.stdout = StringIO() - self.stderr = StringIO() - self._create_project_dir() +# -*- coding: utf-8 -*- \ No newline at end of file diff --git a/tests/base.py b/tests/base.py new file mode 100644 index 0000000..29bb690 --- /dev/null +++ b/tests/base.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +import os +import sys +import shutil +import tempfile +if sys.version_info[:2] < (2, 7): + import unittest2 as unittest +else: + import unittest + +from six import StringIO +from mock import patch + +from djangocms_installer import install + + +class BaseTestClass(unittest.TestCase): + stdout = None + stderr = None + project_dir = None + + def _remove_project_dir(self): + if self.project_dir: + shutil.rmtree(self.project_dir) + self.project_dir = None + + def _create_project_dir(self): + if 'USE_SHM' in os.environ: + if os.path.exists('/run/shm'): + self.project_dir = tempfile.mkdtemp(dir='/run/shm') + elif os.path.exists('/dev/shm'): + self.project_dir = tempfile.mkdtemp(dir='/dev/shm') + else: + self.project_dir = tempfile.mkdtemp() + else: + self.project_dir = tempfile.mkdtemp() + + def tearDown(self): + self._remove_project_dir() + self.stdout = None + self.stderr = None + + def setUp(self): + self.stdout = StringIO() + self.stderr = StringIO() + self._create_project_dir() diff --git a/tests/config.py b/tests/config.py index 92937c6..6cdc58e 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os +import sys import tempfile + from mock import patch from six import StringIO @@ -10,7 +10,7 @@ from djangocms_installer.install import check_install from djangocms_installer.utils import less_than_version, supported_versions -from . import BaseTestClass +from .base import BaseTestClass class TestConfig(BaseTestClass): @@ -38,7 +38,7 @@ def test_cli_config(self): conf_data = config.parse([ '-q', '--db=postgres://user:pwd@host/dbname', - '--cms-version=develop', + '--cms-version=stable', '--django-version=1.4', '--i18n=no', '--reversion=no', @@ -141,7 +141,6 @@ def test_invalid_project_name(self): 'project-name']) self.assertTrue(stderr_tmp.getvalue().find("Project name 'project-name' is not a valid app name") > -1) - def test_invalid_project_path(self): prj_dir = 'example_prj' existing_path = os.path.join(self.project_dir, prj_dir) @@ -165,15 +164,18 @@ def test_latest_version(self): def test_supported_versions(self): self.assertEqual(supported_versions('stable', 'stable'), (1.6, 3.0)) self.assertEqual(supported_versions('stable', '3.0'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'rc'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'beta'), (1.6, 3.0)) - self.assertEqual(supported_versions('stable', 'develop'), (1.6, 3.0)) + self.assertEqual(supported_versions('stable', '3.0.10'), (None, None)) + self.assertEqual(supported_versions('stable', 'rc'), (1.6, 3.1)) + self.assertEqual(supported_versions('stable', 'beta'), (1.6, 3.1)) + self.assertEqual(supported_versions('stable', 'develop'), (1.6, 3.1)) self.assertEqual(supported_versions('stable', '2.4'), (1.5, 2.4)) self.assertEqual(supported_versions('1.5', 'stable'), (1.5, 3.0)) self.assertEqual(supported_versions('1.6', 'stable'), (1.6, 3.0)) - self.assertEqual(supported_versions('beta', 'stable'), (1.6, 3.0)) - self.assertEqual(supported_versions('develop', 'stable'), (1.7, 3.0)) + self.assertEqual(supported_versions('1.6.9', 'stable'), (None, 3.0)) + self.assertEqual(supported_versions('1.7', 'stable'), (1.7, 3.0)) + self.assertEqual(supported_versions('beta', 'stable'), (1.8, 3.0)) + self.assertEqual(supported_versions('develop', 'stable'), (1.8, 3.0)) def test_requirements(self): """ @@ -290,6 +292,8 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_DEVELOP) > -1) self.assertTrue(conf_data.requirements.find('Django<1.6') > -1) + self.assertTrue(conf_data.requirements.find('django-mptt') == -1) + self.assertTrue(conf_data.requirements.find('django-treebeard') > -1) self.assertTrue(conf_data.requirements.find('django-reversion>=1.7,<1.8') > -1) conf_data = config.parse([ @@ -311,6 +315,52 @@ def test_requirements(self): self.assertTrue(conf_data.requirements.find('django-reversion>=1.8') > -1) self.assertTrue(conf_data.requirements.find('pytz') > -1) + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--i18n=no', + '--cms-version=develop', + '--django-version=1.7', + '--reversion=yes', + '-z=yes', + '-p'+self.project_dir, + 'example_prj']) + + self.assertTrue(conf_data.requirements.find(config.data.DJANGOCMS_DEVELOP) > -1) + self.assertTrue(conf_data.requirements.find('Django<1.8') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-text-ckeditor/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-admin-style/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('djangocms-teaser/archive/master.zip') > -1) + self.assertTrue(conf_data.requirements.find('django-reversion>=1.8.2') > -1) + self.assertTrue(conf_data.requirements.find('south') == -1) + + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--cms-version=stable', + '--django-version=stable', + '-a', + '-p'+self.project_dir, + 'example_prj']) + self.assertTrue(conf_data.requirements.find('django-compressor') > -1) + + def test_aldryn_compatibility(self): + with patch('sys.stdout', self.stdout): + with patch('sys.stderr', self.stderr): + with self.assertRaises(SystemExit) as error: + conf_data = config.parse([ + '-q', + '--db=postgres://user:pwd@host/dbname', + '--cms-version=2.4', + '--django-version=stable', + '-a', + '-p'+self.project_dir, + 'example_prj']) + try: + self.assertEqual(error.exception.code, 5) + except AttributeError: + self.assertEqual(error.exception, 5) + def test_boostrap(self): """ Verify handling of bootstrap parameter diff --git a/tests/django.py b/tests/django.py index 58cbf4e..6e72113 100644 --- a/tests/django.py +++ b/tests/django.py @@ -1,14 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os.path -import six -import sqlite3 -from . import unittest import re +import sqlite3 +import sys + +import six from djangocms_installer import config, django, install -from . import BaseTestClass +from djangocms_installer.config.settings import MIGRATION_MODULES +from .base import unittest, BaseTestClass class TestDjango(BaseTestClass): @@ -18,7 +19,7 @@ class TestDjango(BaseTestClass): def test_create_project(self): config_data = config.parse(['--db=postgres://user:pwd@host/dbname', - '--cms-version=develop', + '--cms-version=stable', '-q', '-p'+self.project_dir, 'example_prj']) install.requirements(config_data.requirements) django.create_project(config_data) @@ -26,7 +27,7 @@ def test_create_project(self): def test_copy_data(self): """ - Test corret file copying with different switches + Test correct file copying with different switches """ # Basic template @@ -87,6 +88,26 @@ def test_copy_data(self): self.assertTrue(os.path.exists(starting_page_py)) self.assertTrue(os.path.exists(starting_page_json)) + # Aldryn boilerplate + self._create_project_dir() + config_data = config.parse(['--db=postgres://user:pwd@host/dbname', + '--cms-version=stable', '-a', + '-q', '-p'+self.project_dir, 'example_prj']) + os.makedirs(config_data.project_path) + django.copy_files(config_data) + private_dir = os.path.join(config_data.project_directory, 'private') + static_js = os.path.join(config_data.project_directory, 'static', 'js', 'base.js') + aldryn_template = os.path.join(config_data.project_directory, 'templates', 'fullwidth.html') + basic_template = os.path.join(config_data.project_path, 'templates', 'fullwidth.html') + boostrap_template = os.path.join(config_data.project_path, 'templates', 'feature.html') + custom_template = os.path.join(config_data.project_path, 'templates', 'left.html') + self.assertFalse(os.path.exists(custom_template)) + self.assertFalse(os.path.exists(boostrap_template)) + self.assertFalse(os.path.exists(basic_template)) + self.assertTrue(os.path.exists(private_dir)) + self.assertTrue(os.path.exists(static_js)) + self.assertTrue(os.path.exists(aldryn_template)) + def test_patch_16_settings(self): extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') config_data = config.parse(['--db=sqlite://localhost/test.db', @@ -106,7 +127,7 @@ def test_patch_16_settings(self): globals(), locals(), ['settings']) ## checking for django options - self.assertTrue(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) self.assertEqual(project.settings.MEDIA_URL, '/media/') # Data from external settings file @@ -114,7 +135,60 @@ def test_patch_16_settings(self): self.assertEqual(project.settings.CMS_PERMISSION, False) self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) - def test_patch_16(self): + def test_patch_16_aldryn(self): + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') + config_data = config.parse(['--db=sqlite://localhost/test.db', + '--lang=en', '--extra-settings=%s' % extra_path, + '--django-version=1.6', '-a', + '--cms-version=3.0', '--timezone=Europe/Moscow', + '-q', '-u', '-zno', '--i18n=no', + '-p'+self.project_dir, 'example_path_16_aldryn']) + install.requirements(config_data.requirements) + django.create_project(config_data) + django.patch_settings(config_data) + django.copy_files(config_data) + # settings is importable even in non django environment + sys.path.append(config_data.project_directory) + + project = __import__(config_data.project_name, + globals(), locals(), ['settings']) + + ## checking for django options + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'dist', 'media')) + self.assertEqual(project.settings.TEMPLATE_DIRS, (os.path.join(config_data.project_directory, 'templates'),)) + self.assertEqual(project.settings.MEDIA_URL, '/media/') + + # Data from external settings file + self.assertEqual(project.settings.CUSTOM_SETTINGS_VAR, True) + self.assertEqual(project.settings.CMS_PERMISSION, False) + self.assertEqual(set(project.settings.CMS_TEMPLATES), self.templates_basic) + self.assertTrue('compressor' in project.settings.INSTALLED_APPS) + + def def_test_patch_django_17_settings(self): + extra_path = os.path.join(os.path.dirname(__file__), 'data', 'extra_settings.py') + config_data = config.parse(['--db=sqlite://localhost/test.db', + '--lang=en', '--extra-settings=%s' % extra_path, + '--django-version=1.7', + '--cms-version=stable', '--timezone=Europe/Moscow', + '-q', '-u', '-zno', '--i18n=no', + '-p'+self.project_dir, 'example_path_17_settigns']) + install.requirements(config_data.requirements) + django.create_project(config_data) + django.patch_settings(config_data) + django.copy_files(config_data) + # settings is importable even in non django environment + sys.path.append(config_data.project_directory) + + project = __import__(config_data.project_name, + globals(), locals(), ['settings']) + + ## checking for django options + self.assertFalse('south' in project.settings.INSTALLED_APPS) + for module in MIGRATION_MODULES: + self.assertTrue(module[0] in project.settings.MIGRATION_MODULES.keys()) + self.assertTrue(module[1] in project.settings.MIGRATION_MODULES.values()) + + def test_patch_django_16(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--bootstrap=yes', '--django-version=1.6', @@ -136,7 +210,7 @@ def test_patch_16(self): globals(), locals(), ['settings']) ## checking for django options - self.assertTrue(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) + self.assertEqual(project.settings.MEDIA_ROOT, os.path.join(config_data.project_directory, 'media')) self.assertEqual(project.settings.MEDIA_URL, '/media/') self.assertEqual(project.settings.TIME_ZONE, 'Europe/Moscow') @@ -168,12 +242,11 @@ def test_patch_16(self): self.assertEqual(len(re.findall('BASE_DIR = ', settings)), 1) self.assertEqual(len(re.findall('STATIC_ROOT', settings)), 1) self.assertEqual(len(re.findall('MEDIA_ROOT =', settings)), 1) - self.assertEqual(len(re.findall('STATICFILES_DIRS', settings)), 2) - + self.assertEqual(len(re.findall('STATICFILES_DIRS', settings)), 1) @unittest.skipIf(sys.version_info >= (3, 0), reason="django CMS 2.4 does not support python3") - def test_patch_24_standard(self): + def test_patch_cms_24_standard(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--django-version=1.5', @@ -220,7 +293,7 @@ def test_patch_24_standard(self): @unittest.skipIf(sys.version_info >= (3, 0), reason="django CMS 2.4 does not support python3") - def test_patch_24_filer(self): + def test_patch_cms_24_filer(self): config_data = config.parse(['--db=sqlite://localhost/test.db', '--lang=en', '--django-version=1.5', diff --git a/tests/main.py b/tests/main.py index f25f1f8..5938d71 100644 --- a/tests/main.py +++ b/tests/main.py @@ -1,11 +1,11 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- -import sys import os +import sys + from mock import patch from djangocms_installer import main -from . import BaseTestClass +from .base import BaseTestClass class TestMain(BaseTestClass): @@ -14,7 +14,7 @@ def test_requirements_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=develop', '-R', + '-len', '--cms-version=stable', '-R', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() @@ -38,7 +38,7 @@ def test_main_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '--cms-version=develop', + '-len', '--cms-version=stable', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() @@ -51,7 +51,7 @@ def test_two_langs_invocation(self): with patch('sys.stdout', self.stdout): with patch('sys.stderr', self.stderr): sys.argv = ['main'] + ['--db=sqlite://localhost/test.db', - '-len', '-lfr', '--cms-version=develop', + '-len', '-lfr', '--cms-version=stable', '-q', '-u', '-p'+self.project_dir, 'example_prj'] main.execute() diff --git a/tox.ini b/tox.ini index 8680844..005e899 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist = py26, py27, py33 +envlist = py26, py27, py33, py34 [testenv] recreate=True setenv = PYTHONPATH={toxinidir}:{toxinidir}/djangocms-installer USE_SHM=yes -commands = coverage run setup.py test +commands = python setup.py test deps = -r{toxinidir}/requirements.txt coverage @@ -24,9 +24,16 @@ deps = six coverage +[testenv:py34] +deps = + pip>=1.5 + dj-database-url + six + coverage + [testenv:coverage] commands = - coverage run --source=djangocms-installer setup.py test + coverage run --source=djangocms_installer setup.py test coverage report -m deps = coverage