33import unittest
44
55from dotflow .core .context import Context
6+ from dotflow .core .exception import MissingStepDecorator
67from dotflow .core .task import Task , TaskBuilder
7- from dotflow .core .action import Action as action
88from dotflow .core .utils import callback
99
10-
11- @action
12- def dummy_step ():
13- pass
10+ from tests .mocks import action_step , simple_step
1411
1512
1613class TestTaskBuild (unittest .TestCase ):
@@ -25,7 +22,7 @@ def test_instantiating_class(self):
2522
2623 def test_add_method (self ):
2724 task = TaskBuilder ()
28- task .add (step = dummy_step )
25+ task .add (step = action_step )
2926
3027 self .assertEqual (task .queu [0 ].task_id , 0 )
3128 self .assertIsInstance (task .queu [0 ], Task )
@@ -35,7 +32,7 @@ def test_add_method(self):
3532 def test_add_method_with_class_context (self ):
3633 task = TaskBuilder ()
3734 task .add (
38- step = dummy_step ,
35+ step = action_step ,
3936 initial_context = Context (
4037 storage = self .example
4138 )
@@ -54,7 +51,7 @@ def test_add_method_with_class_context(self):
5451 def test_add_method_without_class_context (self ):
5552 task = TaskBuilder ()
5653 task .add (
57- step = dummy_step ,
54+ step = action_step ,
5855 initial_context = self .example
5956 )
6057
@@ -71,9 +68,30 @@ def test_add_method_without_class_context(self):
7168 def test_count_method (self ):
7269 task = TaskBuilder ()
7370
74- initial_count = task .count ()
75- self .assertEqual (initial_count , 0 )
71+ initial_count = 0
72+ final_count = 1
73+
74+ self .assertEqual (task .count (), initial_count )
75+
76+ task .add (step = action_step )
77+
78+ self .assertEqual (task .count (), final_count )
79+
80+ def test_clear_method (self ):
81+ task = TaskBuilder ()
82+
83+ expected_count_before = 1
84+ expected_count_after = 0
85+
86+ task .add (step = action_step )
87+ self .assertEqual (task .count (), expected_count_before )
88+
89+ task .clear ()
90+
91+ self .assertEqual (task .count (), expected_count_after )
92+
93+ def test_with_step_without_decorator (self ):
94+ task = TaskBuilder ()
7695
77- task .add (step = dummy_step )
78- final_count = task .count ()
79- self .assertEqual (final_count , 1 )
96+ with self .assertRaises (MissingStepDecorator ):
97+ task .add (step = simple_step )
0 commit comments