changeset ddff044e3ce8 in modules/production_routing:default
details: 
https://hg.tryton.org/modules/production_routing?cmd=changeset;node=ddff044e3ce8
description:
        Add test scenario

        review319341002
diffstat:

 setup.py                                   |   5 +-
 tests/scenario_stock_supply_production.rst |  79 ++++++++++++++++++++++++++++++
 tests/test_production_routing.py           |   7 ++
 3 files changed, 90 insertions(+), 1 deletions(-)

diffs (122 lines):

diff -r 27d70f7328b8 -r ddff044e3ce8 setup.py
--- a/setup.py  Fri May 01 00:19:33 2020 +0200
+++ b/setup.py  Fri May 01 00:19:58 2020 +0200
@@ -57,7 +57,10 @@
         requires.append(get_require_version('trytond_%s' % dep))
 requires.append(get_require_version('trytond'))
 
-tests_require = [get_require_version('proteus')]
+tests_require = [
+    get_require_version('proteus'),
+    get_require_version('trytond_stock_supply_production'),
+    ]
 dependency_links = []
 if minor_version % 2:
     dependency_links.append('https://trydevpi.tryton.org/')
diff -r 27d70f7328b8 -r ddff044e3ce8 tests/scenario_stock_supply_production.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/scenario_stock_supply_production.rst        Fri May 01 00:19:58 
2020 +0200
@@ -0,0 +1,79 @@
+===========================
+Production Request Scenario
+===========================
+
+Imports::
+
+    >>> from decimal import Decimal
+    >>> from proteus import Model, Wizard
+    >>> from trytond.tests.tools import activate_modules
+    >>> from trytond.modules.company.tests.tools import (
+    ...     create_company, get_company)
+
+Install stock_supply_production and production_routing Module::
+
+    >>> config = activate_modules(
+    ...     ['stock_supply_production', 'production_routing'])
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Create product::
+
+    >>> ProductUom = Model.get('product.uom')
+    >>> unit, = ProductUom.find([('name', '=', 'Unit')])
+    >>> ProductTemplate = Model.get('product.template')
+
+    >>> template = ProductTemplate()
+    >>> template.name = 'product'
+    >>> template.default_uom = unit
+    >>> template.type = 'goods'
+    >>> template.producible = True
+    >>> template.list_price = Decimal(30)
+    >>> template.save()
+    >>> product, = template.products
+
+Create a Bill of Material with routing::
+
+    >>> BoM = Model.get('production.bom')
+    >>> bom = BoM(name="product")
+    >>> _ = bom.outputs.new(product=product, quantity=1)
+    >>> bom.save()
+    >>> Routing = Model.get('production.routing')
+    >>> routing = Routing(name="product")
+    >>> routing.boms.append(BoM(bom.id))
+    >>> routing.save()
+    >>> product_bom = product.boms.new(bom=bom, routing=routing)
+    >>> product.save()
+
+Get stock locations::
+
+    >>> Location = Model.get('stock.location')
+    >>> storage_loc, = Location.find([('code', '=', 'STO')])
+    >>> lost_loc, = Location.find([('type', '=', 'lost_found')])
+
+Create a need for product::
+
+    >>> Move = Model.get('stock.move')
+    >>> move = Move()
+    >>> move.product = product
+    >>> move.quantity = 1
+    >>> move.from_location = storage_loc
+    >>> move.to_location = lost_loc
+    >>> move.click('do')
+    >>> move.state
+    'done'
+
+Create production request::
+
+    >>> create_pr = Wizard('stock.supply')
+    >>> create_pr.execute('create_')
+
+There is now a production request with the routing::
+
+    >>> Production = Model.get('production')
+    >>> production, = Production.find([])
+    >>> production.routing == routing
+    True
diff -r 27d70f7328b8 -r ddff044e3ce8 tests/test_production_routing.py
--- a/tests/test_production_routing.py  Fri May 01 00:19:33 2020 +0200
+++ b/tests/test_production_routing.py  Fri May 01 00:19:58 2020 +0200
@@ -1,8 +1,11 @@
 # 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 doctest
 import unittest
 import trytond.tests.test_tryton
 from trytond.tests.test_tryton import ModuleTestCase
+from trytond.tests.test_tryton import doctest_teardown
+from trytond.tests.test_tryton import doctest_checker
 
 
 class ProductionRoutingTestCase(ModuleTestCase):
@@ -14,4 +17,8 @@
     suite = trytond.tests.test_tryton.suite()
     suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
             ProductionRoutingTestCase))
+    suite.addTests(doctest.DocFileSuite('scenario_stock_supply_production.rst',
+            tearDown=doctest_teardown, encoding='utf-8',
+            checker=doctest_checker,
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     return suite

Reply via email to