Skip to content

Commit

Permalink
Merge pull request #154 from nephila/more_tests
Browse files Browse the repository at this point in the history
More tests
  • Loading branch information
yakky committed Jan 6, 2015
2 parents 84f0dbb + bf6a1bf commit c236cb6
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions djangocms_installer/config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import argparse
import locale
import os.path
Expand Down
3 changes: 2 additions & 1 deletion djangocms_installer/config/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import time

CONFIGURABLE_OPTIONS = ['--db', '--cms-version', '--django-version', '--i18n',
Expand Down Expand Up @@ -90,7 +91,7 @@

FILER_REQUIREMENTS_CMS3 = """
easy_thumbnails
django-filer>=0.9.6
https://github.com/stefanfoulis/django-filer/archive/develop.zip
cmsplugin-filer>=0.9.9
"""
FILER_REQUIREMENTS_CMS2 = """
Expand Down
1 change: 1 addition & 0 deletions djangocms_installer/config/internal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from argparse import Action
import keyword
import sys
Expand Down
1 change: 1 addition & 0 deletions djangocms_installer/config/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
Expand Down
1 change: 1 addition & 0 deletions djangocms_installer/config/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from cms.sitemaps import CMSSitemap
from django.conf.urls import * # NOQA
from django.conf.urls.i18n import i18n_patterns
Expand Down
1 change: 1 addition & 0 deletions djangocms_installer/django/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from copy import copy, deepcopy
import glob
import os
Expand Down
9 changes: 3 additions & 6 deletions djangocms_installer/install/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os.path
import subprocess


def check_install(config_data):
Expand Down Expand Up @@ -50,18 +52,13 @@ def check_install(config_data):


def requirements(requirements, is_file=False):
import pip
from pip.exceptions import InstallationError
from pip.status_codes import SUCCESS

if is_file: # pragma: no cover
args = ['install', '-q', '-r', requirements]
else:
args = ['install', '-q']
args.extend(['%s' % package for package in requirements.split()])
exit_status = pip.main(args)
if exit_status != SUCCESS:
raise InstallationError("Error while installing requirements. Check pip log file for error details.")
subprocess.check_call(['pip'] + args)
return True


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dj-database-url
pip>=1.5
pip
six
argparse
requests
9 changes: 7 additions & 2 deletions tests/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
import shutil
Expand Down Expand Up @@ -57,15 +58,17 @@ class IsolatedTestClass(BaseTestClass):
def _remove_project_dir(self):
super(IsolatedTestClass, self)._remove_project_dir()
if self.virtualenv_dir:
print("remove virtualenv", self.virtualenv_dir)
shutil.rmtree(self.virtualenv_dir)
self.virtualenv_dir = None

def _create_project_dir(self):
super(IsolatedTestClass, self)._create_project_dir()
self.virtualenv_dir = tempfile.mkdtemp()
print("creating virtualenv", self.virtualenv_dir)

def tearDown(self):
super(IsolatedTestClass, self).tearDown()
print("deactivating virtualenv", self.virtualenv_dir)
if os.path.exists(SYSTEM_ACTIVATE):
try:
execfile(SYSTEM_ACTIVATE, dict(__file__=SYSTEM_ACTIVATE))
Expand All @@ -74,16 +77,18 @@ def tearDown(self):
code = compile(f.read(), SYSTEM_ACTIVATE, 'exec')
exec(code, dict(__file__=SYSTEM_ACTIVATE))
sys.executable = os.path.join(os.path.dirname(SYSTEM_ACTIVATE), 'python')
super(IsolatedTestClass, self).tearDown()

def setUp(self):
super(IsolatedTestClass, self).setUp()
if os.path.exists(SYSTEM_ACTIVATE):
subprocess.check_call(['virtualenv', '--python=%s' % sys.executable, self.virtualenv_dir])
subprocess.check_call(['virtualenv', '-q', '--python=%s' % sys.executable, self.virtualenv_dir])
activate_temp = os.path.join(self.virtualenv_dir, 'bin', 'activate_this.py')
try:
execfile(activate_temp, dict(__file__=activate_temp))
except NameError:
with open(activate_temp) as f:
code = compile(f.read(), activate_temp, 'exec')
exec(code, dict(__file__=activate_temp))
print("activating virtualenv", self.virtualenv_dir)
sys.executable = os.path.join(self.virtualenv_dir, 'bin', 'python')
1 change: 1 addition & 0 deletions tests/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys

Expand Down
1 change: 1 addition & 0 deletions tests/django.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os.path
import re
import sqlite3
Expand Down
3 changes: 3 additions & 0 deletions tests/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
from subprocess import CalledProcessError
import sys
Expand Down Expand Up @@ -89,6 +90,7 @@ def test_django_1_4(self):
with patch('sys.stderr', self.stderr):
sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
'-len', '--django-version=1.4',
'--cms-version=3.0',
'-q', '-u', '-p'+self.project_dir,
'example_prj']
main.execute()
Expand All @@ -102,6 +104,7 @@ def test_django_1_5(self):
with patch('sys.stderr', self.stderr):
sys.argv = ['main'] + ['--db=sqlite://localhost/test.db',
'-len', '--django-version=1.5',
'--cms-version=3.0',
'-q', '-u', '-p'+self.project_dir,
'example_prj']
main.execute()
Expand Down

0 comments on commit c236cb6

Please sign in to comment.