oo_nan_prodlot_quality_control/test/prodlot_with_two_qc_test_di...

367 lines
15 KiB
YAML

-
------ Prodlot Quality Control with Two Trigger Test ------
-
In order to test the workflow and functionality of Production Lots with two
Trigger Test with different Trigger, I create a Lot with two trigger test and
move it for all workflow, from Draft to Valid and to Test Failed, passing by
the Cancel state (and reusing it after that).
-
I create a Production Lot of Product with two QC Test with different triggers
(Lot4)
-
!record {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0}:
product_id: nan_prodlot_quality_control.product_w_2qctest_diff_trigger0
-
I create its Trigger Test calling function 'create_qc_test_triggers' setting
the 'next test' (param of function) for the first trigger and without this
param for the second trigger
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
self.create_qc_test_triggers(cr, uid, lot,
ref('nan_prodlot_quality_control.qc_trigger_demo0'), True, context)
self.create_qc_test_triggers(cr, uid, lot,
ref('nan_prodlot_quality_control.qc_trigger_demo1'), False, context)
-
Checking the Lot4 exists, it has two Trigger Tests with expected Trigger and
Test Template, the Current Test Trigger is the expected and it's in
'Pending Test' state
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'pending_test', "The Lot4 doesn't have the expected " \
"'pending_test' state: %s" % lot.state
assert len(lot.qc_test_trigger_ids) == 2, "The Lot4 doesn't have exactly " \
"two Test Trigger as expected: %d" % len(lot.qc_test_trigger_ids)
assert (lot.qc_test_trigger_ids[0].test_id.test_template_id.id ==
ref('qc_test_template_generic0')), "The Lot4 doesn't have the " \
"expected test template 'Generic Template' in its first Trigger Test: "\
"%s " % lot.qc_test_trigger_ids[0].test_id.test_template_id.name
assert lot.qc_test_trigger_ids[0].trigger_id.id == ref('qc_trigger_demo0'),\
"The Lot4 doesn't have the expected Trigger 'Demo Trigger 1' in its " \
"first Trigger Test: %s " % lot.qc_test_trigger_ids[0].trigger_id.name
assert (lot.qc_test_trigger_ids[1].test_id.test_template_id.id ==
ref('qc_test_template_generic0')), "The Lot4 doesn't have the " \
"expected test template 'Generic Template' in its second Trigger Test:"\
" %s " % lot.qc_test_trigger_ids[1].test_id.test_template_id.name
assert lot.qc_test_trigger_ids[1].trigger_id.id == ref('qc_trigger_demo1'),\
"The Lot4 doesn't have the expected Trigger 'Demo Trigger 2' in its " \
"second Trigger Test: %s " % lot.qc_test_trigger_ids[1].trigger_id.name
assert lot.current_qc_test_trigger_id.id == lot.qc_test_trigger_ids[0].id,\
"The Lot4 doesn't have its first Trigger test as 'Current Trigger " \
"Test': %d != %d" % (lot.current_qc_test_trigger_id.id,
lot.qc_test_trigger_ids[0].id)
-
I fill up the current Quality Test with INVALID values and I Confirm and
Aprove it
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
test_line_id = lot.current_qc_test_id.test_line_ids[0].id
self.pool.get('qc.test.line').write(cr, uid, [test_line_id],
{'actual_value_ql': ref('qc_posible_value_no0')}, context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'confirm', cr)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'approve', cr)
-
Checking Lot4 is in 'test_failed' state (and inactive) because its current QC
Test is in 'fail' state.
-
!assert {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0, string: The Lot4 or its current QC Test aren't in the expected state!}:
- state == 'test_failed'
- active == False
- current_qc_test_id.state == 'failed'
-
I cancel the current Quality Test of Lot4
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'cancel', cr)
-
Checking Lot4 is in 'pending_test' state (and inactive) because its current
QC Test is in 'draft' state.
-
!assert {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0, string: The Lot4 or its current QC Test aren't in the expected state!}:
- state == 'pending_test'
- active == False
- current_qc_test_id.state == 'draft'
-
I Confirm and Aprove the current Quality Test of Lot4
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'confirm', cr)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'approve', cr)
-
Checking Lot4 is in 'test_failed' state (and inactive) because its current
QC Test is in 'fail' state.
-
!assert {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0, string: The Lot4 or its current QC Test aren't in the expected state!}:
- state == 'test_failed'
- active == False
- current_qc_test_id.state == 'failed'
-
I cancel the Lot4 using the function 'action_force_cancel'
-
!python {model: stock.production.lot}: |
self.action_force_cancel(cr, uid, [ref('prodlot_w_2qctest_difftrigger0')],
context)
-
Checking Lot4 is in 'cancel' state and inactive.
-
!assert {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0, string: The Lot4 isn't in the expected state!}:
- state == 'cancel'
- active == False
- not current_qc_test_trigger_id
- qc_test_trigger_ids[0].test_id.state == 'failed'
-
I set to Draft the Lot4 for be able to Cancel the Quality Test.
-
!python {model: stock.production.lot}: |
import netsvc
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'draft', cr)
-
I cancel the first Quality Test of Lot4
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.qc_test_trigger_ids[0].test_id.id, 'cancel', cr)
-
I set the Current Test Trigger and I confirm it.
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
self.write(cr, uid, [ref('prodlot_w_2qctest_difftrigger0')],
{'current_qc_test_trigger_id': lot.qc_test_trigger_ids[0].id}, context)
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'confirm', cr)
-
Checking the 'Current Test Trigger' of Lot4 is the expected and it's in
'Pending Test' state
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'pending_test', "The Lot4 doesn't have the expected " \
"'pending_test' state: %s" % lot.state
assert lot.current_qc_test_trigger_id.id == lot.qc_test_trigger_ids[0].id,\
"The Lot4 doesn't have its Trigger test as 'Current Trigger Test': " \
"%d != %d" % (lot.current_qc_test_trigger_id.id,
lot.qc_test_trigger_ids[0].id)
assert lot.current_qc_test_id.state == 'draft',\
"The Current Test of Lot4 is not in the expected 'Draft' state: %s" \
% lot.current_qc_test_id.state
-
I change the value of current Quality Test with valid value and Confirm and
Aprove it.
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
test_line_id = lot.current_qc_test_id.test_line_ids[0].id
self.pool.get('qc.test.line').write(cr, uid, [test_line_id],
{'actual_value_ql': ref('qc_posible_value_yes0')}, context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'confirm', cr)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'approve', cr)
-
Checking Lot4 is in 'valid' state (and ACTIVE) and doesn't have 'Current Test'
because its first test is 'success' and second is in 'Draft' state.
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'valid', "The Lot4 doesn't have the expected 'valid' " \
"state: %s" % lot.state
assert lot.active == True, "The Lot4 is unexpectly inactive"
assert not lot.current_qc_test_trigger_id, "The Lot4 has unexpectly " \
"Current Test Trigger: %s" % str(lot.current_qc_test_trigger_id)
assert lot.qc_test_trigger_ids[0].test_success == True, "The first " \
"Trigger Test of Lot4 is, unexpectly, not successful: %s" \
% str(lot.qc_test_trigger_ids[0].test_success)
assert lot.qc_test_trigger_ids[1].test_id.state == 'draft', "The second " \
"Trigger Test of Lot4 is, unexpectly, not in 'Draft' state: %s" \
% lot.qc_test_trigger_ids[1].test_id.state
-
Checking that now I can't cancel the Test of first Trigger Test of Lot4
-
!python {model: stock.production.lot}: |
from osv import osv
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
try:
cr.execute('SAVEPOINT not_allwed_cancel')
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.qc_test_trigger_ids[0].test_id.id, 'cancel', cr)
raise Exception("ERROR: We can cancel the First Test of Lot4 (%s) but it "
"shouldn't be able." % str(qc_test_trigger_ids[0]))
except osv.except_osv, e:
print "OK: We can't cancel the First Test of Lot4: %s" % str(e.value)
cr.execute('ROLLBACK TO SAVEPOINT not_allwed_cancel')
-
I cancel the Lot4 using the 'cancel' signal' because from 'Valid' state it's
allowed
-
!python {model: stock.production.lot}: |
import netsvc
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'cancel', cr)
-
Checking Lot4 is in 'Cancel' state and inactive, and doesn't has 'Current
Test' defined.
-
!assert {model: stock.production.lot, id: prodlot_w_2qctest_difftrigger0, string: The Lot4 is not in the expected state!}:
- state == 'cancel'
- active == False
- not current_qc_test_trigger_id
-
I change the state of Lot4 to 'Draft' and I Confirm it without specify any
Current Test.
-
!python {model: stock.production.lot}: |
import netsvc
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'draft', cr)
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'confirm', cr)
-
Checking Lot4 is in 'valid' state (and ACTIVE) because it doesn't have
'Current Test', and its first test is 'success' and second is in 'Draft' state
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'valid', "The Lot4 doesn't have the expected 'valid' " \
"state: %s" % lot.state
assert lot.active == True, "The Lot4 is unexpectly inactive"
assert not lot.current_qc_test_trigger_id, "The Lot4 has unexpectly " \
"Current Test Trigger: %s" % str(lot.current_qc_test_trigger_id)
assert lot.qc_test_trigger_ids[0].test_success == True, "The first " \
"Trigger Test of Lot4 is, unexpectly, not successful: %s" \
% str(lot.qc_test_trigger_ids[0].test_success)
assert lot.qc_test_trigger_ids[1].test_id.state == 'draft', "The second " \
"Trigger Test of Lot4 is, unexpectly, not in 'Draft' state: %s" \
% lot.qc_test_trigger_ids[1].test_id.state
-
I set the second Test Trigger of Lot4 as Current and I raise 'next_test'
signal.
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
self.write(cr, uid, [ref('prodlot_w_2qctest_difftrigger0')],
{'current_qc_test_trigger_id': lot.qc_test_trigger_ids[1].id}, context)
netsvc.LocalService("workflow").trg_validate(uid, 'stock.production.lot',
ref('prodlot_w_2qctest_difftrigger0'), 'next_test', cr)
-
Checking the 'Current Test Trigger' of Lot4 is the expected and it's in
'Pending Test' state
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'pending_test', "The Lot4 doesn't have the expected " \
"'pending_test' state: %s" % lot.state
assert lot.current_qc_test_trigger_id.id == lot.qc_test_trigger_ids[1].id,\
"The Lot4 doesn't have its Trigger test as 'Current Trigger Test': " \
"%d != %d" % (lot.current_qc_test_trigger_id.id,
lot.qc_test_trigger_ids[1].id)
assert lot.current_qc_test_id.state == 'draft',\
"The Current Test of Lot4 is not in the expected 'Draft' state: %s" \
% lot.current_qc_test_id.state
-
I fill up the current Quality Test with valid values and Confirm and Aprove it
-
!python {model: stock.production.lot}: |
import netsvc
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
test_line_id = lot.current_qc_test_id.test_line_ids[0].id
self.pool.get('qc.test.line').write(cr, uid, [test_line_id],
{'actual_value_ql': ref('qc_posible_value_yes0')}, context)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'confirm', cr)
netsvc.LocalService("workflow").trg_validate(uid, 'qc.test',
lot.current_qc_test_id.id, 'approve', cr)
-
Checking Lot4 is in 'valid' state (and ACTIVE) and doesn't have 'Current Test'
because its second test is 'success'.
-
!python {model: stock.production.lot}: |
lot = self.browse(cr, uid, ref('prodlot_w_2qctest_difftrigger0'), context)
assert lot.state == 'valid', "The Lot4 doesn't have the expected 'valid' " \
"state: %s" % lot.state
assert lot.active == True, "The Lot4 is unexpectly inactive"
assert not lot.current_qc_test_trigger_id, "The Lot4 has unexpectly " \
"Current Test Trigger: %s" % str(lot.current_qc_test_trigger_id)
assert lot.qc_test_trigger_ids[1].test_success == True, "The second " \
"Trigger Test of Lot4 is, unexpectly, not successful: %s" \
% str(lot.qc_test_trigger_ids[1].test_success)
-
------ Prodlot Quality Control END OK ------
-
!python {model: stock.production.lot}: |
print "THE END"