From bf1695c07d26cd2cfb5e09e04766f21cdfdecd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 24 Oct 2014 10:45:15 +0200 Subject: [PATCH] Add some test tools to ease scenario writing review11331002 --- tests/scenario_stock_package.rst | 37 ++++++-------------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/tests/scenario_stock_package.rst b/tests/scenario_stock_package.rst index e7e1bcf687..f1cc35a1b0 100644 --- a/tests/scenario_stock_package.rst +++ b/tests/scenario_stock_package.rst @@ -2,10 +2,6 @@ Stock Package Scenario ====================== -============= -General Setup -============= - Imports:: >>> import datetime @@ -13,6 +9,8 @@ Imports:: >>> from decimal import Decimal >>> from proteus import config, Model, Wizard >>> from trytond.exceptions import UserError + >>> from trytond.modules.company.tests.tools import create_company, \ + ... get_company >>> today = datetime.date.today() Create database:: @@ -23,35 +21,14 @@ Create database:: Install stock Module:: >>> Module = Model.get('ir.module.module') - >>> modules = Module.find([('name', '=', 'stock_package')]) - >>> Module.install([x.id for x in modules], config.context) + >>> module, = Module.find([('name', '=', 'stock_package')]) + >>> module.click('install') >>> 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='US Dollar', symbol='$', code='USD', - ... rounding=Decimal('0.01'), mon_grouping='[]', - ... 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() Reload the context:: @@ -111,7 +88,7 @@ Add two shipment lines of same product:: ... move.to_location = customer_loc ... move.company = company ... move.unit_price = Decimal('1') - ... move.currency = currency + ... move.currency = company.currency >>> shipment_out.save() Pack shipment::