def test_build_IOLogRecord_non_ascii_data(self): """ verify that _build_IOLogRecord() checks that ``data`` is ASCII """ with self.assertRaises(CorruptedSessionError) as boom: SessionResumeHelper._build_IOLogRecord([0.0, 'stdout', '\uFFFD']) self.assertIsInstance(boom.exception.__context__, UnicodeEncodeError)
def test_build_IOLogRecord_bad_type_stream_name(self): """ verify that _build_IOLogRecord() checks that ``stream-name`` is a string """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([0.0, 1])
def test_build_IOLogRecord_non_base64_ascii_data(self): """ verify that _build_IOLogRecord() checks that ``data`` is valid base64 """ with self.assertRaises(CorruptedSessionError) as boom: SessionResumeHelper._build_IOLogRecord([0.0, 'stdout', '==broken']) # base64.standard_b64decode() raises binascii.Error self.assertIsInstance(boom.exception.__context__, binascii.Error)
def test_build_IOLogRecord_values(self): """ verify that _build_IOLogRecord() returns a proper IOLogRecord object with all the values in order """ record = SessionResumeHelper._build_IOLogRecord( [1.5, 'stderr', 'dGhpcyB3b3Jrcw==']) self.assertAlmostEqual(record.delay, 1.5) self.assertEqual(record.stream_name, 'stderr') self.assertEqual(record.data, b"this works")
def test_build_IOLogRecord_missing_data(self): """ verify that _build_IOLogRecord() checks for missing ``data`` """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([0.0, 'stdout'])
def test_build_IOLogRecord_bad_value_stream_name(self): """ verify that _build_IOLogRecord() checks that ``stream-name`` looks sane """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([0.0, "foo", ""])
def test_build_IOLogRecord_missing_stream_name(self): """ verify that _build_IOLogRecord() checks for missing ``stream-name`` """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([0.0])
def test_build_IOLogRecord_negative_delay(self): """ verify that _build_IOLogRecord() checks for negative ``delay`` """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([-1.0, 'stdout', ''])
def test_build_IOLogRecord_bad_type_for_delay(self): """ verify that _build_IOLogRecord() checks that ``delay`` is float """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([0, 'stdout', ''])
def test_build_IOLogRecord_missing_delay(self): """ verify that _build_IOLogRecord() checks for missing ``delay`` """ with self.assertRaises(CorruptedSessionError): SessionResumeHelper._build_IOLogRecord([])