From 30c47486c7d684f55db156d8625a8eb7208968c0 Mon Sep 17 00:00:00 2001 From: ?ngel ?lvarez Date: Thu, 3 May 2018 16:45:55 +0200 Subject: [PATCH] update to 4.7 --- .drone.yml | 57 +++++++++++++++++++++++++++ bom.xml | 7 ++++ drawing.xml | 17 ++++++++ production.py | 2 +- production.xml | 7 ++++ setup.py | 45 ++++++++++++++++----- tests/scenario_production.rst | 53 +++++++------------------ tests/test_production_drawing.py | 25 +++++------- tox.ini | 15 +++++++ view/production_drawing_line_form.xml | 3 -- 10 files changed, 164 insertions(+), 67 deletions(-) create mode 100644 .drone.yml create mode 100644 tox.ini diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..897fc2e --- /dev/null +++ b/.drone.yml @@ -0,0 +1,57 @@ +clone: + hg: + image: plugins/hg + +pipeline: + tox: + image: ${IMAGE} + environment: + - CFLAGS=-O0 + - DB_CACHE=/cache + - TOX_TESTENV_PASSENV=CFLAGS DB_CACHE + - POSTGRESQL_URI=postgresql://postgres@postgresql:5432/ + commands: + - pip install tox + - tox -e "${TOXENV}-${DATABASE}" + notify: + image: drillster/drone-email + from: drone@localhost + host: smtp + port: 25 + skip_verify: true + when: + status: [ changed, failure ] + +services: + postgresql: + image: postgres + when: + matrix: + DATABASE: postgresql + +matrix: + include: + - IMAGE: python:2.7 + TOXENV: py27 + DATABASE: sqlite + - IMAGE: python:2.7 + TOXENV: py27 + DATABASE: postgresql + - IMAGE: python:3.4 + TOXENV: py34 + DATABASE: sqlite + - IMAGE: python:3.4 + TOXENV: py34 + DATABASE: postgresql + - IMAGE: python:3.5 + TOXENV: py35 + DATABASE: sqlite + - IMAGE: python:3.5 + TOXENV: py35 + DATABASE: postgresql + - IMAGE: python:3.6 + TOXENV: py36 + DATABASE: sqlite + - IMAGE: python:3.6 + TOXENV: py36 + DATABASE: postgresql diff --git a/bom.xml b/bom.xml index fbdf1d9..b5a7b46 100644 --- a/bom.xml +++ b/bom.xml @@ -27,6 +27,13 @@ + + + + + + + diff --git a/drawing.xml b/drawing.xml index bbfe1ad..09c3107 100644 --- a/drawing.xml +++ b/drawing.xml @@ -35,6 +35,14 @@ + + + + + + + + @@ -67,6 +75,13 @@ + + + + + + + @@ -83,6 +98,8 @@ + + + + + + + + + diff --git a/setup.py b/setup.py index 23ec8d6..97c1f3b 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,11 @@ from setuptools import setup import re import os -import ConfigParser +import io +try: + from configparser import ConfigParser +except ImportError: + from ConfigParser import ConfigParser MODULE = 'production_drawing' PREFIX = 'nantic' @@ -12,7 +16,9 @@ MODULE2PREFIX = {} def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return io.open( + os.path.join(os.path.dirname(__file__), fname), + 'r', encoding='utf-8').read() def get_require_version(name): @@ -24,7 +30,7 @@ def get_require_version(name): major_version, minor_version + 1) return require -config = ConfigParser.ConfigParser() +config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) for key in ('depends', 'extras_depend', 'xml'): @@ -38,14 +44,26 @@ minor_version = int(minor_version) requires = [] for dep in info.get('depends', []): - if not re.match(r'(ir|res|webdav)(\W|$)', dep): + if not re.match(r'(ir|res)(\W|$)', dep): prefix = MODULE2PREFIX.get(dep, 'trytond') - requires.append('%s_%s >= %s.%s, < %s.%s' % - (prefix, dep, major_version, minor_version, - major_version, minor_version + 1)) + requires.append(get_require_version('%s_%s' % (prefix, dep))) requires.append(get_require_version('trytond')) -tests_require = [get_require_version('proteus')] +tests_require = [ + get_require_version('proteus'), +] + +series = '%s.%s' % (major_version, minor_version) +if minor_version % 2: + branch = 'default' +else: + branch = series + +dependency_links = [] + +if minor_version % 2: + # Add development index for testing with proteus + dependency_links.append('https://trydevpi.tryton.org/') setup(name='%s_%s' % (PREFIX, MODULE), version=version, @@ -82,12 +100,17 @@ setup(name='%s_%s' % (PREFIX, MODULE), 'Natural Language :: Russian', 'Natural Language :: Spanish', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Office/Business', ], license='GPL-3', install_requires=requires, + dependency_links=dependency_links, zip_safe=False, entry_points=""" [trytond.modules] @@ -96,4 +119,8 @@ setup(name='%s_%s' % (PREFIX, MODULE), test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_production.rst', + ], ) diff --git a/tests/scenario_production.rst b/tests/scenario_production.rst index bf2ff4a..68e9762 100644 --- a/tests/scenario_production.rst +++ b/tests/scenario_production.rst @@ -12,46 +12,25 @@ Imports:: >>> from dateutil.relativedelta import relativedelta >>> from decimal import Decimal >>> from proteus import config, Model, Wizard + >>> from trytond.tests.tools import activate_modules >>> today = datetime.date.today() >>> yesterday = today - relativedelta(days=1) + >>> from trytond.modules.company.tests.tools import create_company, \ + ... get_company -Create database:: +Install product_cost_plan Module:: - >>> config = config.set_trytond() - >>> config.pool.test = True + >>> config = activate_modules('production_drawing') -Install production Module:: - - >>> Module = Model.get('ir.module.module') - >>> modules = Module.find([('name', '=', 'production_drawing')]) - >>> Module.install([x.id for x in modules], config.context) - >>> Wizard('ir.module.module.install_upgrade').execute('upgrade') Create company:: - >>> Currency = Model.get('currency.currency') - >>> CurrencyRate = Model.get('currency.currency.rate') - >>> Company = Model.get('company.company') - >>> Party = Model.get('party.party') - >>> company_config = Wizard('company.company.config') - >>> company_config.execute('company') - >>> company = company_config.form - >>> party = Party(name='Dunder Mifflin') - >>> party.save() - >>> company.party = party - >>> currencies = Currency.find([('code', '=', 'USD')]) - >>> if not currencies: - ... currency = Currency(name='Euro', symbol=u'$', code='USD', - ... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]', - ... mon_decimal_point=',') - ... currency.save() - ... CurrencyRate(date=today + relativedelta(month=1, day=1), - ... rate=Decimal('1.0'), currency=currency).save() - ... else: - ... currency, = currencies - >>> company.currency = currency - >>> company_config.execute('add') - >>> company, = Company.find() + >>> _ = create_company() + >>> company = get_company() + >>> tax_identifier = company.party.identifiers.new() + >>> tax_identifier.type = 'eu_vat' + >>> tax_identifier.code = 'BE0897290877' + >>> company.party.save() Reload the context:: @@ -67,12 +46,13 @@ Create product:: >>> product = Product() >>> template = ProductTemplate() >>> template.name = 'product' + >>> template.producible = True >>> template.default_uom = unit >>> template.type = 'goods' >>> template.list_price = Decimal(30) - >>> template.cost_price = Decimal(20) >>> template.save() >>> product.template = template + >>> product.cost_price = Decimal(20) >>> product.save() Create Components:: @@ -132,10 +112,7 @@ Create Bill of Material:: >>> output.product = product >>> output.quantity = 1 >>> bom.drawing = drawing - >>> names = [str(x.position.name) for x in bom.drawing_positions] + >>> names = [str(x.position.name) for x in bom.drawing_lines] >>> sorted(names) ['R1', 'R2'] - >>> bom.drawing_positions[0].product = component1 - >>> bom.drawing_positions[1].product = component2 - >>> bom.save() - >>> bom.reload() + diff --git a/tests/test_production_drawing.py b/tests/test_production_drawing.py index 2420786..753e98f 100644 --- a/tests/test_production_drawing.py +++ b/tests/test_production_drawing.py @@ -3,29 +3,22 @@ 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 +from trytond.tests.test_tryton import ModuleTestCase +from trytond.tests.test_tryton import doctest_teardown +from trytond.tests.test_tryton import doctest_checker -class TestCase(unittest.TestCase): +class ProductionDrawingTestCase(ModuleTestCase): 'Test module' - - def setUp(self): - trytond.tests.test_tryton.install_module('production_drawing') - - def test0005views(self): - 'Test views' - test_view('production_drawing') - - def test0006depends(self): - 'Test depends' - test_depends() + module = 'production_drawing' def suite(): suite = trytond.tests.test_tryton.suite() - suite.addTests(unittest.TestLoader().loadTestsFromTestCase(TestCase)) + suite.addTests(unittest.TestLoader().loadTestsFromTestCase( + ProductionDrawingTestCase)) suite.addTests(doctest.DocFileSuite('scenario_production.rst', - setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) return suite diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2082ab4 --- /dev/null +++ b/tox.ini @@ -0,0 +1,15 @@ +[tox] +envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql} + +[testenv] +commands = {envpython} setup.py test +deps = + {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5 + pypy-postgresql: psycopg2cffi >= 2.5 + sqlite: sqlitebck +setenv = + sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} + postgresql: TRYTOND_DATABASE_URI={env:POSTGRESQL_URI:postgresql://} + sqlite: DB_NAME={env:SQLITE_NAME::memory:} + postgresql: DB_NAME={env:POSTGRESQL_NAME:test} +install_command = pip install --pre --process-dependency-links {opts} {packages} diff --git a/view/production_drawing_line_form.xml b/view/production_drawing_line_form.xml index 1ce096f..3b417a4 100644 --- a/view/production_drawing_line_form.xml +++ b/view/production_drawing_line_form.xml @@ -2,9 +2,6 @@
-