0001-esirius_swi-correct-closed-status-computation-62133.patch
passerelle/contrib/esirius_swi/utils.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 | |
18 | 18 |
def compute_status(data): |
19 | 19 |
data.update( |
20 | 20 |
{ |
21 |
'closed': not data['resourceNumber'] or data['estimatedAvgWaitingTime'] == '-',
|
|
21 |
'closed': not data['resourceNumber'], |
|
22 | 22 |
'estimatedAvgWaitingTimeInMinutes': None, |
23 | 23 |
} |
24 | 24 |
) |
25 |
if not data['closed']: |
|
25 |
if not data['closed'] and data['estimatedAvgWaitingTime'] != '-':
|
|
26 | 26 |
values = [int(x) for x in data['estimatedAvgWaitingTime'].split(':')] |
27 | 27 |
data['estimatedAvgWaitingTimeInMinutes'] = 60 * values[0] + values[1] + 1 |
tests/test_esirius_swi.py | ||
---|---|---|
65 | 65 |
assert resp.json['err'] == 1 |
66 | 66 |
assert resp.json['err_desc'] == "'NoneType' object has no attribute 'getroottree'" |
67 | 67 | |
68 | 68 | |
69 | 69 |
@pytest.mark.parametrize( |
70 | 70 |
'resource, time, closed, minutes', |
71 | 71 |
[ |
72 | 72 |
(0, '00:01:39', True, None), |
73 |
(1, '-', True, None),
|
|
73 |
(1, '-', False, None),
|
|
74 | 74 |
(2, '00:01:39', False, 2), |
75 | 75 |
(99, '01:59:00', False, 120), |
76 | 76 |
], |
77 | 77 |
) |
78 | 78 |
def test_status(resource, time, closed, minutes): |
79 | 79 |
data = { |
80 | 80 |
'resourceNumber': resource, |
81 | 81 |
'estimatedAvgWaitingTime': time, |
82 |
- |