## testing.cases()


A Hypothesis strategy of input tables that meet a node's preconditions.


Usage

``` python
testing.cases(
    node,
    *,
    max_rows=5,
)
```


Each example maps the name of each table the node reads (as in [assert_contract](testing.assert_contract.md#sverify.testing.assert_contract)'s `data`) to an Arrow table of at most `max_rows` rows. Values are drawn from small ranges, the boundaries of the constants in the node's plans (`sverify.counterexample`) and NULL for nullable columns; then the rows that violate a precondition (evaluated by Lean, `Rel.eval`) are dropped, repeated keys keep their first row, and a foreign key that matches nothing takes a value of the referenced column (or its row goes). So every example meets the preconditions, and the node's guarantees hold on its output.

Needs Hypothesis (`pip install 'sverify[testing]'`). Integers, doubles, strings, booleans, dates and timestamps without a time zone are supported.


## Parameters


`node: Node`  
A node: a source or node piped into contracted transforms.

`max_rows: int = ``5`  
The most rows per table. Default: 5.


## Returns


`SearchStrategy[dict[str, pa.Table]]`  
A strategy of `{table name: pyarrow.Table}`.


## Raises


`TypeError`  
A column has a type [cases](testing.cases.md#sverify.testing.cases) cannot generate.

`ImportError`  
Hypothesis is not installed.


## Examples

With `doubled` and `orders` from [assert_contract](testing.assert_contract.md#sverify.testing.assert_contract)'s example:

``` python
from hypothesis import given, settings
from sverify.testing import cases

node = orders.pipe(doubled)

@settings(max_examples=10, deadline=None)
@given(cases(node))
def test_doubled(data):
    out = assert_contract(node, data=data)
    assert out.num_rows == data["orders"].num_rows

test_doubled()
```
