changeset b9f0c4001c11 in modules/sale_product_customer:default
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset;node=b9f0c4001c11
description:
        Add test for product customers copy

        issue9017
        review315221002
diffstat:

 tests/scenario_sale_copy_product_customer.rst |  58 +++++++++++++++++++++++++++
 tests/test_sale_product_customer.py           |   5 ++
 2 files changed, 63 insertions(+), 0 deletions(-)

diffs (75 lines):

diff -r 3bef7a63ee9c -r b9f0c4001c11 
tests/scenario_sale_copy_product_customer.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/scenario_sale_copy_product_customer.rst     Fri May 01 20:33:05 
2020 +0200
@@ -0,0 +1,58 @@
+===================================
+Sale Copy Product Customer Scenario
+===================================
+
+Imports::
+
+    >>> from decimal import Decimal
+    >>> from proteus import Model
+    >>> from trytond.tests.tools import activate_modules
+    >>> from trytond.modules.company.tests.tools import create_company, \
+    ...     get_company
+
+Install purchase::
+
+    >>> config = activate_modules('sale_product_customer')
+
+Create company::
+
+    >>> _ = create_company()
+    >>> company = get_company()
+
+Create party::
+
+    >>> Party = Model.get('party.party')
+    >>> customer = Party(name='customer')
+    >>> customer.save()
+
+Create a product with customers::
+
+    >>> 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.salable = True
+    >>> template.list_price = Decimal('10')
+    >>> template.cost_price_method = 'fixed'
+    >>> product_customer = template.product_customers.new()
+    >>> product_customer.party = customer
+    >>> template.save()
+    >>> product, = template.products
+    >>> product_customer = product.product_customers.new()
+    >>> product_customer.party = customer
+    >>> product_customer.template == template
+    True
+    >>> product.save()
+
+Customer is copied when copying the template::
+
+    >>> template_copy, = template.duplicate()
+    >>> product_copy, = template_copy.products
+    >>> len(template_copy.product_customers)
+    2
+    >>> len(product_copy.product_customers)
+    1
diff -r 3bef7a63ee9c -r b9f0c4001c11 tests/test_sale_product_customer.py
--- a/tests/test_sale_product_customer.py       Fri May 01 20:32:37 2020 +0200
+++ b/tests/test_sale_product_customer.py       Fri May 01 20:33:05 2020 +0200
@@ -26,4 +26,9 @@
             tearDown=doctest_teardown, encoding='utf-8',
             checker=doctest_checker,
             optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
+    suite.addTests(doctest.DocFileSuite(
+            'scenario_sale_copy_product_customer.rst',
+            tearDown=doctest_teardown, encoding='utf-8',
+            checker=doctest_checker,
+            optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
     return suite

Reply via email to