Skip to content

Commit 2a18525

Browse files
Merge pull request #71 from QualiSystems/bug/output_to_reservation_fails
initial
2 parents 7beb63f + 9b319af commit 2a18525

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

package/cloudshell/cm/customscript/domain/reservation_output_writer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ def write_warning(self, msg):
2020

2121
def _remove_illegal_chars(self, str):
2222
rx = re.compile('\x00')
23+
str = str if not getattr(str, "decode", False) else str.decode() # can be a bytes-like object
2324
return rx.sub('', str)

package/tests/test_reservation_output_writer.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ def test_write(self):
1414
writer = ReservationOutputWriter(session, context)
1515
writer.write('some msg')
1616
session.WriteMessageToReservationOutput.assert_called_once_with('1234','some msg')
17+
18+
def test_write_with_bytes(self):
19+
session = Mock()
20+
context = Mock()
21+
context.reservation.reservation_id = '1234'
22+
writer = ReservationOutputWriter(session, context)
23+
writer.write(b'some msg')
24+
session.WriteMessageToReservationOutput.assert_called_once_with('1234','some msg')

0 commit comments

Comments
 (0)