def test_simple_serialization(): serializer = CSVEncodedList() values = None db_contents = serializer.process_bind_param(values, DB_DIALECT) assert db_contents is None values = ["hello", "world"] db_contents = serializer.process_bind_param(values, DB_DIALECT) assert db_contents == "hello,world"
def test_matrix_serialization(): serializer = CSVEncodedList(matrix=True) values = None db_contents = serializer.process_bind_param(values, DB_DIALECT) assert db_contents is None values = [["hello", "world"], ["lorem", "ipsum"]] db_contents = serializer.process_bind_param(values, DB_DIALECT) assert db_contents == "hello,world\r\nlorem,ipsum" values = [["hello", "world"], ["foo", "bar", "baz"], ["lorem", "ipsum"]] db_contents = serializer.process_bind_param(values, DB_DIALECT) assert db_contents == "hello,world\r\nfoo,bar,baz\r\nlorem,ipsum"