|
| 1 | +import pytest |
| 2 | +import datetime |
| 3 | + |
| 4 | +IN_RECORD = (42, 84, 126) |
| 5 | +IN_VARRAY = list(range(10, 0, -1)) |
| 6 | +IN_NESTED = [i * 2 for i in range(1, 11)] |
| 7 | +IN_PLSQL_TABLE = {i: i for i in range(1, 11)} |
| 8 | + |
| 9 | +OUT_RECORD = (42, 84, 126) |
| 10 | +OUT_VARRAY = list(range(10, 0, -1)) |
| 11 | +OUT_NESTED = [i * 2 for i in range(1, 11)] |
| 12 | +OUT_PLSQL_TABLE = {i: i for i in range(1, 11)} |
| 13 | + |
| 14 | + |
| 15 | +@pytest.mark.parametrize( |
| 16 | + "func, in_value, out_value", |
| 17 | + [ |
| 18 | + ("io_varchar2", "42", "42"), |
| 19 | + ("io_varchar", "42", "42"), |
| 20 | + ("io_string", "42", "42"), |
| 21 | + ("io_number", 42.42, 42.42), |
| 22 | + ("io_integer", 42.0, 42.0), |
| 23 | + ("io_smallint", 42.0, 42.0), |
| 24 | + ("io_real", 42.42, 42.42), |
| 25 | + ("io_float", 42.42, 42.42), |
| 26 | + ("io_numeric", 42.0, 42.0), |
| 27 | + ("io_decimal", 42.0, 42.0), |
| 28 | + ("io_binary_integer", 42, 42), |
| 29 | + ("io_pls_integer", 42, 42), |
| 30 | + ("io_positive", 42, 42), |
| 31 | + ("io_natural", 42, 42), |
| 32 | + ("io_clob", "42", "42"), |
| 33 | + ("io_long", "42", "42"), |
| 34 | + ("io_rowid", "AAAACPAABAAAAShAAA", "AAAACPAABAAAAShAAA"), |
| 35 | + ( |
| 36 | + "io_date", |
| 37 | + datetime.datetime(year=2019, month=12, day=20), |
| 38 | + datetime.datetime(year=2019, month=12, day=20), |
| 39 | + ), |
| 40 | + ( |
| 41 | + "io_timestamp", |
| 42 | + datetime.datetime(year=2019, month=12, day=20), |
| 43 | + datetime.datetime(year=2019, month=12, day=20), |
| 44 | + ), |
| 45 | + ("io_raw", b"42", b"42"), |
| 46 | + ("io_long_raw", b"42", b"42"), |
| 47 | + ("io_char", "42".ljust(12000, " "), "42".ljust(12000, " ")), |
| 48 | + ("io_character", "42".ljust(12000, " "), "42".ljust(12000, " ")), |
| 49 | + ("io_bool", True, True), |
| 50 | + ("io_record", IN_RECORD, IN_RECORD), |
| 51 | + pytest.param( |
| 52 | + "io_record_of_records", |
| 53 | + (42, IN_RECORD, IN_RECORD), |
| 54 | + (42, IN_RECORD, IN_RECORD), |
| 55 | + marks=pytest.mark.skip( |
| 56 | + reason="OCI-21602: operation does not support the specified typecode" |
| 57 | + ), |
| 58 | + ), |
| 59 | + ("io_record_of_nested", (42, IN_NESTED, IN_NESTED), (42, IN_NESTED, IN_NESTED)), |
| 60 | + ( |
| 61 | + "io_record_of_plsql_table", |
| 62 | + (42, IN_PLSQL_TABLE, IN_PLSQL_TABLE), |
| 63 | + (42, IN_PLSQL_TABLE, IN_PLSQL_TABLE), |
| 64 | + ), |
| 65 | + ("io_nested", IN_NESTED, IN_NESTED), |
| 66 | + ("io_nested_of_records", [IN_RECORD] * 10, [IN_RECORD] * 10), |
| 67 | + ( |
| 68 | + "io_nested_of_record_of_nested", |
| 69 | + [(42, IN_NESTED, IN_NESTED)] * 10, |
| 70 | + [(42, IN_NESTED, IN_NESTED)] * 10, |
| 71 | + ), |
| 72 | + ("io_varray", IN_VARRAY, IN_VARRAY), |
| 73 | + ("io_plsql_table", IN_PLSQL_TABLE, IN_PLSQL_TABLE), |
| 74 | + ( |
| 75 | + "io_plsql_table_of_records", |
| 76 | + {i: IN_RECORD for i in range(1, 11)}, |
| 77 | + {i: IN_RECORD for i in range(1, 11)}, |
| 78 | + ), |
| 79 | + pytest.param( |
| 80 | + "io_varray_of_plsql_table", |
| 81 | + [IN_PLSQL_TABLE] * 10, |
| 82 | + [IN_PLSQL_TABLE] * 10, |
| 83 | + marks=pytest.mark.skip("Memory access violation"), |
| 84 | + ), |
| 85 | + pytest.param( |
| 86 | + "io_varray_of_nested", |
| 87 | + [IN_NESTED] * 10, |
| 88 | + [IN_NESTED] * 10, |
| 89 | + marks=pytest.mark.skip("Memory access violation"), |
| 90 | + ), |
| 91 | + pytest.param( |
| 92 | + "io_plsql_table_of_nested", |
| 93 | + {i: IN_NESTED for i in range(1, 11)}, |
| 94 | + {i: IN_NESTED for i in range(1, 11)}, |
| 95 | + marks=pytest.mark.skip("Memory access violation"), |
| 96 | + ), |
| 97 | + pytest.param( |
| 98 | + "io_nested_of_nested", |
| 99 | + [IN_NESTED] * 10, |
| 100 | + [IN_NESTED] * 10, |
| 101 | + marks=pytest.mark.skip("Memory access violation"), |
| 102 | + ), |
| 103 | + pytest.param( |
| 104 | + "io_nested_of_plsql_table", |
| 105 | + [IN_PLSQL_TABLE] * 10, |
| 106 | + [IN_PLSQL_TABLE] * 10, |
| 107 | + marks=pytest.mark.skip("Memory access violation"), |
| 108 | + ), |
| 109 | + pytest.param( |
| 110 | + "io_plsql_table_of_plsql_table", |
| 111 | + {i: IN_PLSQL_TABLE for i in range(1, 11)}, |
| 112 | + {i: IN_PLSQL_TABLE for i in range(1, 11)}, |
| 113 | + marks=pytest.mark.skip("Memory access violation"), |
| 114 | + ), |
| 115 | + ], |
| 116 | +) |
| 117 | +def test_return_values(plsql, func, in_value, out_value): |
| 118 | + assert getattr(plsql.test_in_out_params, func)(in_value).p_param == out_value |
0 commit comments