From 9b319af48ff81c0311a9e4c0ce8da28be0c85519 Mon Sep 17 00:00:00 2001 From: "QUALISYSTEMS\\nahum-t" Date: Mon, 3 May 2021 10:15:40 +0300 Subject: [PATCH] initial --- .../cm/customscript/domain/reservation_output_writer.py | 1 + package/tests/test_reservation_output_writer.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/package/cloudshell/cm/customscript/domain/reservation_output_writer.py b/package/cloudshell/cm/customscript/domain/reservation_output_writer.py index 88fca8f..9abb7f6 100644 --- a/package/cloudshell/cm/customscript/domain/reservation_output_writer.py +++ b/package/cloudshell/cm/customscript/domain/reservation_output_writer.py @@ -20,4 +20,5 @@ def write_warning(self, msg): def _remove_illegal_chars(self, str): rx = re.compile('\x00') + str = str if not getattr(str, "decode", False) else str.decode() # can be a bytes-like object return rx.sub('', str) \ No newline at end of file diff --git a/package/tests/test_reservation_output_writer.py b/package/tests/test_reservation_output_writer.py index 861c577..ba3f4a9 100644 --- a/package/tests/test_reservation_output_writer.py +++ b/package/tests/test_reservation_output_writer.py @@ -14,3 +14,11 @@ def test_write(self): writer = ReservationOutputWriter(session, context) writer.write('some msg') session.WriteMessageToReservationOutput.assert_called_once_with('1234','some msg') + + def test_write_with_bytes(self): + session = Mock() + context = Mock() + context.reservation.reservation_id = '1234' + writer = ReservationOutputWriter(session, context) + writer.write(b'some msg') + session.WriteMessageToReservationOutput.assert_called_once_with('1234','some msg')