[ADD] setup.py and basic tests
This commit is contained in:
parent
2a1c8b6b22
commit
5ac583caa7
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/env python
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
|
||||
from setuptools import setup
|
||||
import re
|
||||
import os
|
||||
import ConfigParser
|
||||
|
||||
|
||||
def read(fname):
|
||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.readfp(open('tryton.cfg'))
|
||||
info = dict(config.items('tryton'))
|
||||
for key in ('depends', 'extras_depend', 'xml'):
|
||||
if key in info:
|
||||
info[key] = info[key].strip().splitlines()
|
||||
major_version, minor_version, _ = info.get('version', '0.0.1').split('.', 2)
|
||||
major_version = int(major_version)
|
||||
minor_version = int(minor_version)
|
||||
|
||||
requires = []
|
||||
for dep in info.get('depends', []):
|
||||
if not re.match(r'(ir|res|webdav)(\W|$)', dep):
|
||||
requires.append('trytond_%s >= %s.%s, < %s.%s' %
|
||||
(dep, major_version, minor_version, major_version,
|
||||
minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1))
|
||||
|
||||
setup(name='trytonnan_module_source',
|
||||
version=info.get('version', '0.0.1'),
|
||||
description='Tryton module to manage sources of Tryton modules',
|
||||
long_description=read('README'),
|
||||
author='Tryton',
|
||||
url='http://www.nan-tic.com/',
|
||||
download_url="https://bitbucket.org/nantic/python-pypi_client/downloads",
|
||||
package_dir={'trytond.modules.module_source': '.'},
|
||||
packages=[
|
||||
'trytond.modules.module_source',
|
||||
'trytond.modules.module_source.tests',
|
||||
],
|
||||
package_data={
|
||||
'trytond.modules.module_source': info.get('xml', []) \
|
||||
+ ['tryton.cfg', 'locale/*.po', '*.odt', 'icons/*.svg'],
|
||||
},
|
||||
classifiers=[
|
||||
# 'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Plugins',
|
||||
'Framework :: Tryton',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: GNU General Public License (GPL)',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Topic :: Office/Business',
|
||||
],
|
||||
license='GPL-3',
|
||||
install_requires=requires,
|
||||
extras_require={
|
||||
'PypiClient': ['pypi_client'],
|
||||
},
|
||||
zip_safe=False,
|
||||
entry_points="""
|
||||
[trytond.modules]
|
||||
module_source = trytond.modules.module_source
|
||||
""",
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
|
||||
from .test_module_source import suite
|
|
@ -0,0 +1,78 @@
|
|||
#!/usr/bin/env python
|
||||
#This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
#this repository contains the full copyright notices and license terms.
|
||||
import sys
|
||||
import os
|
||||
DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
|
||||
'..', '..', '..', '..', '..', 'trytond')))
|
||||
if os.path.isdir(DIR):
|
||||
sys.path.insert(0, os.path.dirname(DIR))
|
||||
|
||||
import unittest
|
||||
import trytond.tests.test_tryton
|
||||
from trytond.tests.test_tryton import POOL, DB_NAME, USER, CONTEXT, test_view,\
|
||||
test_depends
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
class ModuleSourceTestCase(unittest.TestCase):
|
||||
'''
|
||||
Test Module Source module.
|
||||
'''
|
||||
|
||||
def setUp(self):
|
||||
trytond.tests.test_tryton.install_module('module_source')
|
||||
self.module_source_serie = POOL.get('ir.module.source.serie')
|
||||
self.module_source = POOL.get('ir.module.source')
|
||||
self.party = POOL.get('party.party')
|
||||
|
||||
def test0005views(self):
|
||||
'''
|
||||
Test views.
|
||||
'''
|
||||
test_view('module_source')
|
||||
|
||||
def test0006depends(self):
|
||||
'''
|
||||
Test depends.
|
||||
'''
|
||||
test_depends()
|
||||
|
||||
def test0010serie(self):
|
||||
'''
|
||||
Create serie.
|
||||
'''
|
||||
with Transaction().start(DB_NAME, USER,
|
||||
context=CONTEXT) as transaction:
|
||||
serie28 = self.module_source_serie.create({
|
||||
'name': '2.8',
|
||||
'stable': False,
|
||||
})
|
||||
self.assert_(serie28.id)
|
||||
transaction.cursor.commit()
|
||||
|
||||
def test0020source(self):
|
||||
'''
|
||||
Create source.
|
||||
'''
|
||||
with Transaction().start(DB_NAME, USER,
|
||||
context=CONTEXT) as transaction:
|
||||
party1 = self.party.search([], limit=1)
|
||||
serie1 = self.module_source_serie.search([], limit=1)
|
||||
source1 = self.module_source.create({
|
||||
'name': 'Source 1',
|
||||
'author': party1 and party1[0].id,
|
||||
'server_serie': serie1[0].id,
|
||||
})
|
||||
self.assert_(source1.id)
|
||||
transaction.cursor.commit()
|
||||
|
||||
|
||||
def suite():
|
||||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader()\
|
||||
.loadTestsFromTestCase(ModuleSourceTestCase))
|
||||
return suite
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.TextTestRunner(verbosity=2).run(suite())
|
Loading…
Reference in New Issue