/usr/lib/python2.7/dist-packages/trytond/modules/stock_lot_sled/tests/test_stock_lot_sled.py is in tryton-modules-stock-lot-sled 4.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # 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 unittest
import datetime
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
from trytond.transaction import Transaction
from trytond.pool import Pool
from trytond.modules.company.tests import create_company, set_company
class StockLotSLEDTestCase(ModuleTestCase):
'Test Stock Lot SLED module'
module = 'stock_lot_sled'
longMessage = True
@with_transaction()
def test_sled(self):
'Test SLED'
pool = Pool()
Uom = pool.get('product.uom')
Template = pool.get('product.template')
Product = pool.get('product.product')
Location = pool.get('stock.location')
Date = pool.get('ir.date')
Move = pool.get('stock.move')
Lot = pool.get('stock.lot')
Period = pool.get('stock.period')
u, = Uom.search([('name', '=', 'Unit')])
template = Template(
name='Test SLED',
type='goods',
list_price=0,
cost_price=0,
default_uom=u,
shelf_life_state='optional',
)
template.save()
product = Product(template=template)
product.save()
supplier, = Location.search([('code', '=', 'SUP')])
storage, = Location.search([('code', '=', 'CUS')])
company = create_company()
with set_company(company):
today = Date.today()
lot = Lot(
number='Test',
product=product,
shelf_life_expiration_date=today + datetime.timedelta(days=5),
)
lot.save()
move = Move(
product=product,
uom=u,
quantity=5,
from_location=supplier,
to_location=storage,
planned_date=today,
company=company,
unit_price=0,
currency=company.currency,
lot=lot,
)
move.save()
period = Period(date=today + datetime.timedelta(days=-10),
company=company)
period.save()
Period.close([period])
empty = {}
computed = {(storage.id, product.id): 5}
for context, result in [
({'stock_date_end': today + datetime.timedelta(days=-1)},
empty),
({'stock_date_end': today}, empty),
({'stock_date_end': today, 'forecast': True}, computed),
({'stock_date_end': today + datetime.timedelta(days=3)},
computed),
({'stock_date_end': today + datetime.timedelta(days=5)},
computed),
({'stock_date_end': today + datetime.timedelta(days=6)},
empty),
({}, empty),
]:
with Transaction().set_context(context=context,
locations=[storage.id]):
quantity = Product.products_by_location(
[storage.id], [product.id])
self.assertEqual(quantity, result,
msg='context: %s' % repr(context))
def suite():
suite = trytond.tests.test_tryton.suite()
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
StockLotSLEDTestCase))
return suite
|