first commit
This commit is contained in:
2
modules/carrier_subdivision/tests/__init__.py
Normal file
2
modules/carrier_subdivision/tests/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,121 @@
|
||||
============================
|
||||
Carrier Subdivision Scenario
|
||||
============================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['carrier_subdivision', 'sale_shipment_cost'], create_company)
|
||||
|
||||
Create subdivisions::
|
||||
|
||||
>>> Country = Model.get('country.country')
|
||||
>>> Subdivision = Model.get('country.subdivision')
|
||||
>>> spain = Country(name='Spain', code='ES')
|
||||
>>> spain.save()
|
||||
>>> catalonia = Subdivision()
|
||||
>>> catalonia.code = 'ES-CAT'
|
||||
>>> catalonia.name = 'Catalonia'
|
||||
>>> catalonia.country = spain
|
||||
>>> catalonia.type = 'autonomous community'
|
||||
>>> catalonia.save()
|
||||
>>> barcelona = Subdivision()
|
||||
>>> barcelona.code = 'ES-BCN'
|
||||
>>> barcelona.name = 'Barcelona'
|
||||
>>> barcelona.country = spain
|
||||
>>> barcelona.type = 'province'
|
||||
>>> barcelona.parent = catalonia
|
||||
>>> barcelona.save()
|
||||
>>> madrid = Subdivision()
|
||||
>>> madrid.code = 'ES-MAD'
|
||||
>>> madrid.name = 'Madrid'
|
||||
>>> madrid.country = spain
|
||||
>>> madrid.type = 'province'
|
||||
>>> madrid.save()
|
||||
|
||||
Create customers::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> address, = customer.addresses
|
||||
>>> address.country = spain
|
||||
>>> address.subdivision = madrid
|
||||
>>> customer.save()
|
||||
>>> other_customer = Party(name='Other Customer')
|
||||
>>> address, = other_customer.addresses
|
||||
>>> address.country = spain
|
||||
>>> address.subdivision = barcelona
|
||||
>>> other_customer.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.salable = True
|
||||
>>> carrier_template.list_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carriers::
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
>>> catalan_carrier = Carrier()
|
||||
>>> party = Party(name='Catalan Carrier')
|
||||
>>> party.save()
|
||||
>>> catalan_carrier.party = party
|
||||
>>> catalan_carrier.carrier_product = carrier_product
|
||||
>>> catalan_carrier.save()
|
||||
|
||||
Set subdivision for each carrier::
|
||||
|
||||
>>> CarrierSelection = Model.get('carrier.selection')
|
||||
>>> csc = CarrierSelection()
|
||||
>>> csc.carrier = catalan_carrier
|
||||
>>> csc.to_country = spain
|
||||
>>> csc.to_subdivision = catalonia
|
||||
>>> csc.sequence = 10
|
||||
>>> csc.save()
|
||||
>>> csc = CarrierSelection()
|
||||
>>> csc.carrier = carrier
|
||||
>>> csc.to_country = spain
|
||||
>>> csc.sequence = 20
|
||||
>>> csc.save()
|
||||
|
||||
Test right carrier is used on sale::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> assertEqual(sale.carrier, carrier)
|
||||
>>> sale.carrier = None
|
||||
>>> sale.party = other_customer
|
||||
>>> assertEqual(sale.carrier, catalan_carrier)
|
||||
@@ -0,0 +1,91 @@
|
||||
========================================
|
||||
Carrier Subdivision Postal Code Scenario
|
||||
========================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from decimal import Decimal
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.company.tests.tools import create_company
|
||||
>>> from trytond.tests.tools import activate_modules, assertEqual
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules(
|
||||
... ['carrier_subdivision', 'sale_shipment_cost'], create_company)
|
||||
|
||||
Create customers::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> address, = customer.addresses
|
||||
>>> address.postal_code = '08080'
|
||||
>>> customer.save()
|
||||
>>> other_customer = Party(name='Other Customer')
|
||||
>>> address, = other_customer.addresses
|
||||
>>> address.postal_code = '25175'
|
||||
>>> other_customer.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'Product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('20')
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
|
||||
>>> carrier_template = ProductTemplate()
|
||||
>>> carrier_template.name = 'Carrier Product'
|
||||
>>> carrier_template.default_uom = unit
|
||||
>>> carrier_template.type = 'service'
|
||||
>>> carrier_template.salable = True
|
||||
>>> carrier_template.list_price = Decimal('3')
|
||||
>>> carrier_template.save()
|
||||
>>> carrier_product, = carrier_template.products
|
||||
|
||||
Create carriers::
|
||||
|
||||
>>> Carrier = Model.get('carrier')
|
||||
>>> carrier = Carrier()
|
||||
>>> party = Party(name='Carrier')
|
||||
>>> party.save()
|
||||
>>> carrier.party = party
|
||||
>>> carrier.carrier_product = carrier_product
|
||||
>>> carrier.save()
|
||||
>>> local_carrier = Carrier()
|
||||
>>> party = Party(name='Local Carrier')
|
||||
>>> party.save()
|
||||
>>> local_carrier.party = party
|
||||
>>> local_carrier.carrier_product = carrier_product
|
||||
>>> local_carrier.save()
|
||||
|
||||
Create postal code selection for each carrier::
|
||||
|
||||
>>> CarrierSelection = Model.get('carrier.selection')
|
||||
>>> csc = CarrierSelection()
|
||||
>>> csc.carrier = local_carrier
|
||||
>>> csc.to_postal_code = '25'
|
||||
>>> csc.sequence = 10
|
||||
>>> csc.save()
|
||||
>>> csc = CarrierSelection()
|
||||
>>> csc.carrier = carrier
|
||||
>>> csc.sequence = 20
|
||||
>>> csc.save()
|
||||
|
||||
Test right carrier is used on sale::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> assertEqual(sale.carrier, carrier)
|
||||
>>> sale.carrier = None
|
||||
>>> sale.party = other_customer
|
||||
>>> assertEqual(sale.carrier, local_carrier)
|
||||
13
modules/carrier_subdivision/tests/test_module.py
Normal file
13
modules/carrier_subdivision/tests/test_module.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import ModuleTestCase
|
||||
|
||||
|
||||
class CarrierSubdivisionTestCase(ModuleTestCase):
|
||||
"Test Carrier Subdivision module"
|
||||
module = 'carrier_subdivision'
|
||||
extras = ['carrier_carriage', 'sale_shipment_cost']
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/carrier_subdivision/tests/test_scenario.py
Normal file
8
modules/carrier_subdivision/tests/test_scenario.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user