@@ -39,9 +39,8 @@ def test_create_incident_report_creates_new_state_transition(self):
39
39
40
40
class TestTransitionStateUpdateFromAssetStatusModification (CoreBaseTestCase ):
41
41
"""
42
- Test updating of transition state when Asset status is modified
43
- Update the transition state to CLOSED when an Asset status is changed from (DAMAGED,LOST) to
44
- either (AVAILABLE,ALLOCATED)
42
+ Test updating the transition state to CLOSED when an Asset status is changed from ALLOCATED to
43
+ either (AVAILABLE,DAMAGED,LOST)
45
44
"""
46
45
47
46
def setUp (self ):
@@ -59,90 +58,44 @@ def setUp(self):
59
58
).objects .get_or_create (asset_incident_report_id = self .incident_report .id )
60
59
self .transition_state = self .transition_state [0 ]
61
60
62
- def test_update_asset_status_from_lost_to_available (self ):
63
- status = (
64
- apps .get_model ("core" , "AssetStatus" )
65
- .objects .filter (asset = self .asset )
66
- .latest ('created_at' )
67
- )
68
- # update status to lost
69
- status .current_status = constants .LOST
70
- status .save ()
71
- # update status to available
72
- status = (
73
- apps .get_model ("core" , "AssetStatus" )
74
- .objects .filter (asset = self .asset )
75
- .latest ('created_at' )
76
- )
77
- status .current_status = constants .AVAILABLE
78
- status .save ()
79
- # verify that transition state has been updated to closed
80
- transition_state = apps .get_model ("core" , "StateTransition" ).objects .get (
81
- asset_incident_report = self .incident_report
82
- )
83
- self .assertEqual (transition_state .incident_report_state , constants .CLOSED )
84
-
85
- def test_update_asset_status_from_damaged_to_available (self ):
61
+ def test_update_asset_status_from_allocated_to_lost (self ):
86
62
status = (
87
63
apps .get_model ("core" , "AssetStatus" )
88
64
.objects .filter (asset = self .asset )
89
65
.latest ('created_at' )
90
66
)
91
67
92
- # update status to lost
93
- status .current_status = constants .DAMAGED
94
- status .save ()
95
- # update status to available
96
- status = (
97
- apps .get_model ("core" , "AssetStatus" )
98
- .objects .filter (asset = self .asset )
99
- .latest ('created_at' )
100
- )
101
- status .current_status = constants .AVAILABLE
102
- status .save ()
103
- # verify that transition state has been updated to closed
104
- transition_state = apps .get_model ("core" , "StateTransition" ).objects .get (
105
- asset_incident_report = self .incident_report
106
- )
107
- self .assertEqual (transition_state .incident_report_state , constants .CLOSED )
108
-
109
- def test_update_asset_status_from_lost_to_allocated (self ):
110
- status = (
111
- apps .get_model ("core" , "AssetStatus" )
112
- .objects .filter (asset = self .asset )
113
- .latest ('created_at' )
68
+ # allocate asset to a user
69
+ apps .get_model ("core" , "AllocationHistory" ).objects .create (
70
+ asset = self .asset , current_assignee = self .asset_assignee2
114
71
)
115
72
116
73
# update status to lost
117
74
status .current_status = constants .LOST
118
75
status .save ()
119
76
120
- # allocate asset to a user
121
- apps .get_model ("core" , "AllocationHistory" ).objects .create (
122
- asset = self .asset , current_assignee = self .asset_assignee2
123
- )
124
-
125
77
transition_state = apps .get_model ("core" , "StateTransition" ).objects .get (
126
78
asset_incident_report = self .incident_report
127
79
)
128
80
129
81
self .assertEqual (transition_state .incident_report_state , constants .CLOSED )
130
82
131
- def test_update_asset_status_from_damaged_to_allocated (self ):
83
+ def test_update_asset_status_from_allocated_to_damaged (self ):
132
84
status = (
133
85
apps .get_model ("core" , "AssetStatus" )
134
86
.objects .filter (asset = self .asset )
135
87
.latest ('created_at' )
136
88
)
137
89
138
- # update status to lost
139
- status .current_status = constants .DAMAGED
140
- status .save ()
141
90
# allocate asset to a user
142
91
apps .get_model ("core" , "AllocationHistory" ).objects .create (
143
92
asset = self .asset , current_assignee = self .asset_assignee2
144
93
)
145
94
95
+ # update status to DAMAGED
96
+ status .current_status = constants .DAMAGED
97
+ status .save ()
98
+
146
99
transition_state = apps .get_model ("core" , "StateTransition" ).objects .get (
147
100
asset_incident_report = self .incident_report
148
101
)
@@ -167,9 +120,11 @@ def test_update_asset_status_from_allocated_to_available(self):
167
120
)
168
121
self .assertEqual (status .current_status , constants .ALLOCATED )
169
122
123
+ # update status to AVAILABLE
124
+ status .current_status = constants .AVAILABLE
125
+ status .save ()
126
+
170
127
transition_state = apps .get_model ("core" , "StateTransition" ).objects .get (
171
128
asset_incident_report = self .incident_report
172
129
)
173
- self .assertEqual (
174
- transition_state .incident_report_state , constants .NEWLY_REPORTED
175
- )
130
+ self .assertEqual (transition_state .incident_report_state , constants .CLOSED )
0 commit comments