Beispiel #1
0
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"
Beispiel #2
0
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"