From 916d3f9729de0695e7feab29f4debdaa427b29fa Mon Sep 17 00:00:00 2001 From: resteve Date: Mon, 18 Jan 2016 23:01:36 +0100 Subject: [PATCH] Initial commit --- CHANGELOG | 1 + COPYRIGHT | 14 +++++++ INSTALL | 27 ++++++++++++ README | 40 ++++++++++++++++++ setup.py | 42 +++++++++++++++++++ trytontasks_tests/__init__.py | 79 +++++++++++++++++++++++++++++++++++ trytontasks_tests/version.py | 8 ++++ 7 files changed, 211 insertions(+) create mode 100644 CHANGELOG create mode 100644 COPYRIGHT create mode 100644 INSTALL create mode 100644 README create mode 100644 setup.py create mode 100644 trytontasks_tests/__init__.py create mode 100644 trytontasks_tests/version.py diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1 @@ + diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 0000000..d031ec5 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,14 @@ +Copyright (C) 2015 TrytonSpain + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..beac0ef --- /dev/null +++ b/INSTALL @@ -0,0 +1,27 @@ +Installing trytontasks-tests +============================ + +Prerequisites +------------- + + * Python 2.7 or later (http://www.python.org/) + * invoke (https://pypi.python.org/pypi/invoke/) + * See requeriments.txt + +Installation +------------ + +Once you've downloaded and unpacked the trytond_esale source release, enter the +directory where the archive was unpacked, and run: + + python setup.py install + +Note that you may need administrator/root privileges for this step, as +this command will by default attempt to install module to the Python +site-packages directory on your system. + +For advanced options, please refer to the easy_install and/or the distutils +documentation: + + http://peak.telecommunity.com/DevCenter/EasyInstall + http://docs.python.org/inst/inst.html diff --git a/README b/README new file mode 100644 index 0000000..c9c6ced --- /dev/null +++ b/README @@ -0,0 +1,40 @@ +Tryton Tasks Tests +================== + +Test modules and pyflakes + +Installing +---------- + +See INSTALL + +Support +------- + +For more information or if you encounter any problems with this module, +please contact the programmers at + + TrytonSpain + ----------- + website: http://www.tryton-erp.es/ + project: https://bitbucket.org/trytonspain/ + +If you encounter any problems with Tryton, please don't hesitate to ask +questions on the Tryton bug tracker, mailing list, wiki or IRC channel: + + https://bitbucket.org/trytonspain/ + +License +------- + +See LICENSE + +Copyright +--------- + +See COPYRIGHT + + +For more information please visit the Tryton web site: + + http://www.tryton-erp.es/ diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..b0438e4 --- /dev/null +++ b/setup.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +#This file is part of trytontasks_tests. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. +from setuptools import setup, find_packages +import os + +execfile(os.path.join('trytontasks_tests', 'version.py')) + +def read(fname): + return open(os.path.join(os.path.dirname(__file__), fname)).read() + + +setup(name=PACKAGE, + version=VERSION, + description='Tryton Tasks Tests', + long_description=read('README'), + author=AUTHOR, + url=WEBSITE, + download_url="https://bitbucket.org/trytonspain/trytontasks-tests", + packages=find_packages(), + package_data={}, + scripts=[], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: No Input/Output (Daemon)', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License (GPL)', + 'Operating System :: OS Independent', + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Topic :: Software Development :: Libraries', + ], + license=LICENSE, + install_requires=[ + 'invoke>=0.11.1', + 'blessings', + 'pyflakes', + ], + extras_require={}, + zip_safe=False, + #~ test_suite='trytontasks_tests.tests', + ) diff --git a/trytontasks_tests/__init__.py b/trytontasks_tests/__init__.py new file mode 100644 index 0000000..aa9a774 --- /dev/null +++ b/trytontasks_tests/__init__.py @@ -0,0 +1,79 @@ +#This file is part of trytontasks_tests. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. +import functools +import unittest +import time +import os +from invoke import task, run +from blessings import Terminal +from trytontasks_modules import read_config_file +from trytond.config import config + +t = Terminal() + +@task +def test(dbtype='sqlite', module=None): + 'Run Tryton test module/s' + Modules = read_config_file() + modules = Modules.sections() + modules.sort() + + if module: + if not module in modules: + print "Not found " + t.bold(module) + return + modules = [module] + + if dbtype == 'sqlite': + configfile = 'sqlite.conf' + database_name = ':memory:' + else: + configfile = 'trytond.conf' + database_name = 'test_' + str(int(time.time())) + + if not os.path.exists(configfile): + print "Not found " + t.bold(configfile) + return + + os.environ['DB_NAME'] = database_name + + import trytond.tests.test_tryton as test_tryton + + print "Run %s in %s database" % ('all' if len(modules) > 1 else module, database_name) + + config.update_etc(configfile) + update_etc = functools.partial(config.update_etc, configfile) + config.update_etc = lambda *args, **kwargd: update_etc() + #~ config.update_etc(options) + config.update_etc = lambda *args, **kwargs: None + + suite = test_tryton.modules_suite(modules=modules) + text_runner = unittest.TextTestRunner().run(suite) + print text_runner + +@task +def pyflakes(module=None): + 'Run Tryton test module/s' + Modules = read_config_file() + + # remove base (trytond, tryton, proteus...) + Bases = read_config_file('base.cfg') + bases = Bases.sections() + for base in bases: Modules.remove_section(base) + + modules = Modules.sections() + modules.sort() + + if module: + if not module in modules: + print "Not found " + t.bold(module) + return + modules = [module] + + for module in modules: + path = '%s/%s' % (Modules.get(module, 'path'), module) + files = [] + for f in sorted(os.listdir(path)): + if f.endswith('.py') and f not in ['__init__.py', 'setup.py']: + files.append('%s/%s' % (path, f)) + run('pyflakes %s' % ' '.join(files)) diff --git a/trytontasks_tests/version.py b/trytontasks_tests/version.py new file mode 100644 index 0000000..c4d6b3c --- /dev/null +++ b/trytontasks_tests/version.py @@ -0,0 +1,8 @@ +#This file is part of trytontasks_tests. The COPYRIGHT file at the top level of +#this repository contains the full copyright notices and license terms. + +PACKAGE = 'trytontasks_tests' +VERSION = '0.0.1' +LICENSE = 'GPL-3' +WEBSITE = 'http://www.tryton-erp.es/' +AUTHOR = 'TrytonSpain'