Add tests and tox
This commit is contained in:
parent
49db9449ef
commit
402be58c43
8
setup.py
8
setup.py
|
@ -34,6 +34,8 @@ for dep in info.get('depends', []):
|
|||
major_version, minor_version + 1))
|
||||
requires.append('trytond >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1))
|
||||
tests_require = ['proteus >= %s.%s, < %s.%s' %
|
||||
(major_version, minor_version, major_version, minor_version + 1)]
|
||||
|
||||
setup(name='%s_%s' % (PREFIX, MODULE),
|
||||
version=info.get('version', '0.0.1'),
|
||||
|
@ -48,7 +50,8 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po']),
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po',
|
||||
'country_zip_es.csv']),
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
|
@ -73,4 +76,7 @@ setup(name='%s_%s' % (PREFIX, MODULE),
|
|||
[trytond.modules]
|
||||
%s = trytond.modules.%s
|
||||
""" % (MODULE, MODULE),
|
||||
test_suite='tests',
|
||||
test_loader='trytond.test_loader:Loader',
|
||||
tests_require=tests_require,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
#This file is part bank_es module for Tryton.
|
||||
#The COPYRIGHT file at the top level of this repository contains
|
||||
#the full copyright notices and license terms.
|
||||
|
||||
from .test_country_zip_es import suite
|
||||
|
||||
__all__ = ['suite']
|
|
@ -0,0 +1,36 @@
|
|||
=======================
|
||||
Country Zip ES Scenario
|
||||
=======================
|
||||
|
||||
Imports::
|
||||
>>> import datetime
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
>>> from decimal import Decimal
|
||||
>>> from operator import attrgetter
|
||||
>>> from proteus import config, Model, Wizard
|
||||
>>> today = datetime.date.today()
|
||||
|
||||
Create database::
|
||||
|
||||
>>> config = config.set_trytond()
|
||||
>>> config.pool.test = False
|
||||
|
||||
Install account_invoice::
|
||||
|
||||
>>> Module = Model.get('ir.module.module')
|
||||
>>> module, = Module.find([('name', '=', 'country_zip_es')])
|
||||
>>> Module.install([module.id], config.context)
|
||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
||||
|
||||
Load all spanish banks::
|
||||
|
||||
>>> Wizard('load.country.zips').execute('accept')
|
||||
|
||||
Ensure that banks are loaded::
|
||||
|
||||
>>> CountryZip = Model.get('country.zip')
|
||||
>>> czip, = CountryZip.find([('zip', '=', '25001')])
|
||||
>>> czip.city
|
||||
u'Lleida'
|
||||
>>> czip.country.code
|
||||
u'ES'
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
# This file is part country_zip_es module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
import unittest
|
||||
import doctest
|
||||
import trytond.tests.test_tryton
|
||||
from trytond.tests.test_tryton import test_view, test_depends
|
||||
from trytond.tests.test_tryton import doctest_setup, doctest_teardown
|
||||
|
||||
|
||||
class CountryZipEsTestCase(unittest.TestCase):
|
||||
'Test Spanish Country Zip module'
|
||||
|
||||
def setUp(self):
|
||||
trytond.tests.test_tryton.install_module('country_zip_es')
|
||||
|
||||
def test0005views(self):
|
||||
'Test views'
|
||||
test_view('country_zip_es')
|
||||
|
||||
def test0006depends(self):
|
||||
'Test depends'
|
||||
test_depends()
|
||||
|
||||
|
||||
def suite():
|
||||
suite = trytond.tests.test_tryton.suite()
|
||||
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
|
||||
CountryZipEsTestCase))
|
||||
suite.addTests(doctest.DocFileSuite('scenario_country_zip_es.rst',
|
||||
setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8',
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
return suite
|
|
@ -0,0 +1,12 @@
|
|||
[tox]
|
||||
envlist = py27-{sqlite,postgresql}
|
||||
|
||||
[testenv]
|
||||
commands = {envpython} setup.py test
|
||||
deps =
|
||||
postgresql: psycopg2 >= 2.0
|
||||
setenv =
|
||||
sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}
|
||||
sqlite: DB_NAME={env:SQLITE_NAME::memory:}
|
||||
postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://}
|
||||
postgresql: DB_NAME={env:POSTGRESQL_NAME:test}
|
Loading…
Reference in New Issue