/usr/lib/python2.7/dist-packages/trytond/modules/stock_lot_sled/tests/test_stock_lot_sled.py is in tryton-modules-stock-lot-sled 3.8.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 106 107 108 109 110 111 112 113 114 115 116 117 | # 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 doctest
import datetime
import trytond.tests.test_tryton
from trytond.tests.test_tryton import ModuleTestCase
from trytond.tests.test_tryton import DB_NAME, USER, CONTEXT
from trytond.pool import Pool
from trytond.transaction import Transaction
class StockLotSLEDTestCase(ModuleTestCase):
'Test Stock Lot SLED module'
module = 'stock_lot_sled'
longMessage = True
def test_sled(self):
'Test SLED'
with Transaction().start(DB_NAME, USER, context=CONTEXT):
pool = Pool()
Uom = pool.get('product.uom')
Template = pool.get('product.template')
Product = pool.get('product.product')
Location = pool.get('stock.location')
Company = pool.get('company.company')
User = pool.get('res.user')
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, = Company.search([
('rec_name', '=', 'Dunder Mifflin'),
])
user = User(USER)
user.main_company = company
user.company = company
user.save()
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()
from trytond.modules.company.tests import test_company
for test in test_company.suite():
if test not in suite and not isinstance(test, doctest.DocTestCase):
suite.addTest(test)
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(
StockLotSLEDTestCase))
return suite
|