55
66from odoo .addons .queue_job .job import identity_exact
77from odoo .addons .queue_job .tests .common import mock_with_delay
8- from odoo .addons .sale_automatic_workflow .tests .test_automatic_workflow_base import ( # noqa
9- TestAutomaticWorkflowBase ,
8+ from odoo .addons .sale_automatic_workflow .tests .common import (
9+ TestAutomaticWorkflowMixin ,
10+ TestCommon ,
1011)
1112
1213
1314@tagged ("post_install" , "-at_install" )
14- class TestAutoWorkflowJob (TestAutomaticWorkflowBase ):
15- def setUp (self ):
16- super ().setUp ()
17- workflow = self .create_full_automatic ()
18- self .sale = self .create_sale_order (workflow )
19-
15+ class TestAutoWorkflowJob (TestCommon , TestAutomaticWorkflowMixin ):
2016 def assert_job_delayed (self , delayable_cls , delayable , method_name , args ):
2117 # .with_delay() has been called once
2218 self .assertEqual (delayable_cls .call_count , 1 )
@@ -33,46 +29,56 @@ def assert_job_delayed(self, delayable_cls, delayable, method_name, args):
3329 self .assertDictEqual (delay_kwargs , {})
3430
3531 def test_validate_sale_order (self ):
32+ workflow = self .create_full_automatic ()
33+ self .sale = self .create_sale_order (workflow )
3634 with mock_with_delay () as (delayable_cls , delayable ):
37- self .progress () # run automatic workflow cron
35+ self .run_job () # run automatic workflow cron
3836 self .assert_job_delayed (
3937 delayable_cls , delayable , "_do_validate_sale_order" , (self .sale ,)
4038 )
4139
4240 def test_create_invoice (self ):
41+ workflow = self .create_full_automatic ()
42+ self .sale = self .create_sale_order (workflow )
4343 self .sale .action_confirm ()
4444 # don't care about transfers in this test
4545 self .sale .picking_ids .state = "done"
4646 with mock_with_delay () as (delayable_cls , delayable ):
47- self .progress () # run automatic workflow cron
47+ self .run_job () # run automatic workflow cron
4848 self .assert_job_delayed (
4949 delayable_cls , delayable , "_do_create_invoice" , (self .sale ,)
5050 )
5151
5252 def test_validate_invoice (self ):
53+ workflow = self .create_full_automatic ()
54+ self .sale = self .create_sale_order (workflow )
5355 self .sale .action_confirm ()
5456 # don't care about transfers in this test
5557 self .sale .picking_ids .state = "done"
5658 self .sale .action_invoice_create ()
5759 invoice = self .sale .invoice_ids
5860 with mock_with_delay () as (delayable_cls , delayable ):
59- self .progress () # run automatic workflow cron
61+ self .run_job () # run automatic workflow cron
6062 self .assert_job_delayed (
6163 delayable_cls , delayable , "_do_validate_invoice" , (invoice ,)
6264 )
6365
6466 def test_validate_picking (self ):
67+ workflow = self .create_full_automatic ()
68+ self .sale = self .create_sale_order (workflow )
6569 self .sale .action_confirm ()
6670 picking = self .sale .picking_ids
6771 # disable invoice creation in this test
6872 self .sale .workflow_process_id .create_invoice = False
6973 with mock_with_delay () as (delayable_cls , delayable ):
70- self .progress () # run automatic workflow cron
74+ self .run_job () # run automatic workflow cron
7175 self .assert_job_delayed (
7276 delayable_cls , delayable , "_do_validate_picking" , (picking ,)
7377 )
7478
7579 def test_sale_done (self ):
80+ workflow = self .create_full_automatic ()
81+ self .sale = self .create_sale_order (workflow )
7682 self .sale .action_confirm ()
7783 # don't care about transfers in this test
7884 self .sale .picking_ids .state = "done"
@@ -85,7 +91,7 @@ def test_sale_done(self):
8591 self .sale .workflow_process_id .sale_done = True
8692
8793 with mock_with_delay () as (delayable_cls , delayable ):
88- self .progress () # run automatic workflow cron
94+ self .run_job () # run automatic workflow cron
8995 self .assert_job_delayed (
9096 delayable_cls , delayable , "_do_sale_done" , (self .sale ,)
9197 )
0 commit comments