From 009e51b738aca5ee415ed35c6b0eff843f1b4a42 Mon Sep 17 00:00:00 2001 From: Gust Date: Mon, 6 Apr 2015 19:01:10 -0300 Subject: [PATCH] Add/fix colab_gitlab tests --- .gitignore | 1 + MANIFEST.in | 2 +- setup.py | 71 +++++++++++++++++++++++++++++++++++++++-------------------------------- tests/__init__.py | 0 tests/config_settings.py | 11 +++++++++++ tests/plugins.d/gitlab.py | 23 +++++++++++++++++++++++ tests/run.py | 37 +++++++++++++++++++++++++++++++++++++ tests/settings.py | 39 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 151 insertions(+), 33 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/config_settings.py create mode 100644 tests/plugins.d/gitlab.py create mode 100755 tests/run.py create mode 100644 tests/settings.py diff --git a/.gitignore b/.gitignore index 0a7f916..e57c014 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ ext/ colab_gitlab.egg-info dist +.coverage diff --git a/MANIFEST.in b/MANIFEST.in index 0dc2d85..1b5a97b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ include README.rst include MANIFEST.in -recursive-include colab *.html *.txt *.xml +recursive-include colab_gitlab *.html *.txt *.xml recursive-exclude * __pycache__ recursive-exclude * *.py[co] include requirements.txt diff --git a/setup.py b/setup.py index 3a51efc..377a455 100644 --- a/setup.py +++ b/setup.py @@ -1,47 +1,54 @@ +import codecs +import os +import re -from setuptools import setup, find_packages -from pip.download import PipSession -from pip.req import parse_requirements +from setuptools import setup -import os # if you are not using vagrant, just delete os.link directly, # The hard link only saves a little disk space, so you should not care if os.environ.get('USER', '') == 'vagrant': del os.link -session = PipSession() -reqs = [str(req.req) for req in parse_requirements('requirements.txt', - session=session) if req.req] +def read(*parts): + return codecs.open(os.path.join(os.path.dirname(__file__), *parts), + encoding='utf8').read() + -EXCLUDE_FROM_PACKAGES = [] +def find_version(*file_paths): + version_file = read(*file_paths) + version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", + version_file, re.M) + if version_match: + return version_match.group(1) + raise RuntimeError("Unable to find version string.") setup( name='colab-gitlab', - version='0.1.0', - url='https://github.com/colab-community/colab_gitlab', + url='https://github.com/colab/colab_gitlab', + description='Yet another Django reverse proxy application.', + version=find_version('colab_gitlab/__init__.py'), + long_description=read('README.rst'), + packages=['colab_gitlab'], + install_requires=[ + 'colab', + ], + tests_require=['mock', 'diazo', ], + test_suite="tests.run.runtests", author='Sergio Oliveira', author_email='sergio@tracy.com.br', - description= - 'Gitlab plugin for Colab, a colaboration platform for communities', - license='LICENSE.txt', - packages=find_packages(exclude="EXCLUDE_FROM_PACKAGES"), - include_package_data=True, - namespace_packages=['colab', 'colab.proxy'], - zip_safe=False, - long_description=open('README.rst').read(), - install_requires=reqs, - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Environment :: Web Environment', - 'Framework :: Django', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Topic :: Internet :: WWW/HTTP', - 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', - 'Topic :: Internet :: WWW/HTTP :: WSGI', - ], + license='GPL 2.0', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Environment :: Web Environment', + 'Framework :: Django', + 'Intended Audience :: Developers', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Topic :: Internet :: WWW/HTTP :: WSGI', + ], ) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/config_settings.py b/tests/config_settings.py new file mode 100644 index 0000000..c7c6f26 --- /dev/null +++ b/tests/config_settings.py @@ -0,0 +1,11 @@ +SECRET_KEY = 'ddddddddddddddddddddddddddddddddddddddddddddddddddddddaddddddddd' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'HOST': 'localhost', + 'NAME': 'colab', + 'USER': 'colab', + 'PASSWORD': 'colab', + } +} diff --git a/tests/plugins.d/gitlab.py b/tests/plugins.d/gitlab.py new file mode 100644 index 0000000..d64cd22 --- /dev/null +++ b/tests/plugins.d/gitlab.py @@ -0,0 +1,23 @@ +from django.utils.translation import ugettext_lazy as _ +from colab.plugins.utils.menu import colab_url_factory + +name = 'colab_gitlab' +verbose_name = 'Gitlab Proxy' + +upstream = 'localhost' +#middlewares = [] + +urls = { + 'include': 'colab_gitlab.urls', + 'namespace': 'gitlab', + 'prefix': 'gitlab', +} + +menu_title = _('Code') + +url = colab_url_factory('gitlab') + +menu_urls = ( + url(display=_('Profile'), viewname='gitlab', kwargs={'path': '/profile/anonymous'}, auth=False), + url(display=_('Profile Two'), viewname='gitlab', kwargs={'path': '/profile/logged'}, auth=True), +) diff --git a/tests/run.py b/tests/run.py new file mode 100755 index 0000000..c65158c --- /dev/null +++ b/tests/run.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import os +import sys + +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' +os.environ['COLAB_SETTINGS'] = 'tests/config_settings.py' +os.environ['COLAB_YAML_SETTINGS'] = 'tests/settings.yaml' +os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' +os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' +os.environ['REUSE_DB'] = '0' + +import django +import coverage + +from django.test.utils import get_runner +from django.conf import settings + + +def runtests(): + if django.VERSION >= (1, 7, 0): + django.setup() + + test_runner = get_runner(settings) + failures = test_runner(interactive=False, failfast=False).run_tests([]) + sys.exit(failures) + + +def run_with_coverage(): + if os.path.exists('.coverage'): + os.remove('.coverage') + coverage.process_startup() + runtests() + + +if __name__ == '__main__': + run_with_coverage() diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..d7670d2 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,39 @@ +from colab.settings import * # noqa + +SOCIAL_NETWORK_ENABLED = True +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' + +LOGGING = { + 'version': 1, + + 'handlers': { + 'null': { + 'level': 'DEBUG', + 'class': 'logging.NullHandler', + }, + }, + + 'loggers': { + 'colab.mailman': { + 'handlers': ['null'], + 'propagate': False, + }, + 'haystack': { + 'handlers': ['null'], + 'propagate': False, + }, + 'pysolr': { + 'handlers': ['null'], + 'propagate': False, + }, + }, +} + +import os +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', + 'URL': 'http://127.0.0.1:8983/solr' + }, +} + -- libgit2 0.21.2