changeset 67433b35ecf5 in modules/stock_supply:default details: https://hg.tryton.org/modules/stock_supply?cmd=changeset;node=67433b35ecf5 description: Add test for order point location's searcher
issue8141 review58531002 diffstat: tests/test_stock_supply.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diffs (52 lines): diff -r b5dff78398eb -r 67433b35ecf5 tests/test_stock_supply.py --- a/tests/test_stock_supply.py Fri Mar 15 17:49:32 2019 +0100 +++ b/tests/test_stock_supply.py Fri Mar 15 17:49:59 2019 +0100 @@ -118,6 +118,48 @@ }]) return product_supplier + @with_transaction() + def test_order_point_location_searcher(self): + pool = Pool() + Uom = pool.get('product.uom') + Template = pool.get('product.template') + Product = pool.get('product.product') + Location = pool.get('stock.location') + OrderPoint = pool.get('stock.order_point') + unit, = Uom.search([('symbol', '=', 'u')]) + template, = Template.create([{ + 'name': 'ProductTest', + 'type': 'goods', + 'default_uom': unit.id, + 'purchase_uom': unit.id, + 'list_price': Decimal(0), + 'purchasable': True, + }]) + product, = Product.create([{ + 'template': template.id, + }]) + + warehouse, = Location.search([('type', '=', 'warehouse')]) + storage, = Location.search([('code', '=', 'STO')]) + + company = create_company() + with set_company(company): + order_point, = OrderPoint.create([{ + 'product': product.id, + 'type': 'purchase', + 'warehouse_location': warehouse.id, + 'target_quantity': 5.0, + }]) + + for clause, result in [ + (('location', '=', warehouse.name), [order_point]), + (('location', '=', 'storage'), []), + (('location', '!=', warehouse.name), []), + (('location', '!=', 'storage'), [order_point]), + ]: + self.assertListEqual( + OrderPoint.search(clause), result, msg=clause) + def suite(): suite = trytond.tests.test_tryton.suite()