def test_decode_record(self): msg = f('A|B|C|D') res = [['A', 'B', 'C', 'D']] self.assertEqual(res, codec.decode(msg))
def test_decode_message_with_nonascii(self): msg = f('{STX}1Й|Ц|У|К{CR}{ETX}F1{CRLF}', 'cp1251') res = [[u('Й'), u('Ц'), u('У'), u('К')]] self.assertEqual(res, codec.decode(msg, 'cp1251'))
def test_decode_frame(self): msg = f('1A|B|C|D{CR}{ETX}') res = [['A', 'B', 'C', 'D']] self.assertEqual(res, codec.decode(msg))
def test_join_chunks(self): recs = [['foo', '1'], ['bar', '24'], ['baz', ['1', '2', '3'], 'boo']] chunks = codec.encode(recs, size=14) msg = codec.join(chunks) self.assertEqual(codec.decode(msg), recs)
def test_decode_message(self): msg = f('{STX}1A|B|C|D{CR}{ETX}BF{CRLF}') res = [['A', 'B', 'C', 'D']] self.assertEqual(res, codec.decode(msg))
def test_decode_record(self): msg = f("A|B|C|D") res = [["A", "B", "C", "D"]] self.assertEqual(res, codec.decode(msg))
def test_decode_chunks(self): recs = [['foo', 1], ['bar', 24], ['baz', [1, 2, 3], 'boo']] res = codec.encode(recs, size=14) for item in res: codec.decode(item)
def test_decode_frame(self): msg = f("1A|B|C|D{CR}{ETX}") res = [["A", "B", "C", "D"]] self.assertEqual(res, codec.decode(msg))
def test_decode_message_with_nonascii(self): msg = f("{STX}1Й|Ц|У|К{CR}{ETX}F1{CRLF}", "cp1251") res = [[u("Й"), u("Ц"), u("У"), u("К")]] self.assertEqual(res, codec.decode(msg, "cp1251"))
def test_decode_message(self): msg = f("{STX}1A|B|C|D{CR}{ETX}BF{CRLF}") res = [["A", "B", "C", "D"]] self.assertEqual(res, codec.decode(msg))
def test_join_chunks(self): recs = [["foo", "1"], ["bar", "24"], ["baz", ["1", "2", "3"], "boo"]] chunks = codec.encode(recs, size=14) msg = codec.join(chunks) self.assertEqual(codec.decode(msg), recs)
def test_decode_chunks(self): recs = [["foo", 1], ["bar", 24], ["baz", [1, 2, 3], "boo"]] res = codec.encode(recs, size=14) for item in res: codec.decode(item)