# ...

@responses.activate
def test_sdk_list_products_sort_by_price_desc():
    store_id = 1
    responses.add(
        responses.GET,
        api_url + f"/store/{store_id}/product",
        json=[
            {"id": 1, "name": "Banana", "price": 0.5},
            {"id": 2, "name": "Apple", "price": 0.3},
        ],
        status=200,
        match=[matchers.header_matcher({"X-API-KEY": api_key})],
    )

    sdk = EComSDK(api_url, api_key)
    products = sdk.list_products(store_id, sort_by=EComSDK.ProductSort.PRICE, sort_order=EComSDK.ProductSortOrder.DESC)

    assert len(products) == 2
    assert products[0]["id"] == 1
    assert products[0]["name"] == "Banana"
    assert products[1]["id"] == 2
    assert products[1]["name"] == "Apple"
```

Check that the new test passes:

```bash
hatch run test
```

## Output Type Safety With Pydantic

To make the SDK even more user-friendly, we can use Pydantic to create data models for the responses from the ECOM API.

First, add Pydantic to the project dependencies in the `pyproject.toml` file:

```toml
dependencies = [
  "requests",
  "responses",
  "pydantic",
]
```

Now, create a `Product` model in the `./src/ecom_sdk/models.py` file:

```python filename="src/ecom_sdk/models.py"
from pydantic import BaseModel

class Product(BaseModel):
    id: int
    name: str
    price: float
```

Next, import the `Product` model into the `./src/ecom_sdk/sdk.py` file:

```python filename="src/ecom_sdk/sdk.py"
from .models import Product
```

Modify the `list_products()` function to return a list of `Product` models:

```python filename="src/ecom_sdk/sdk.py"