---
sidebar:
  label: roboto.testing.fake_http_response_factory
  order: 0
title: roboto.testing.fake_http_response_factory
---
## Module Contents

### FakeHttpResponseFactory

```python
class roboto.testing.fake_http_response_factory.FakeHttpResponseFactory(
    url: str = 'https://test.roboto.ai',
    response_data: Any = '{}',
    status_code: int = 200,
    headers: Optional[dict[str, str]] = None,
)
```

`from roboto.testing import FakeHttpResponseFactory`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/testing/fake_http_response_factory.py#L16-L59)

A factory for creating fake HTTP responses, for use with the roboto.http.HttpClient.

**Usage**

```python
import contextlib
import unittest.mock
from roboto.http import HttpClient, FakeHttpResponseFactory
mock_http_client = unittest.mock.create_autospec(HttpClient, instance=True)
with contextlib.ExitStack() as stack:
    http_get_mock = stack.enter_context(unittest.mock.patch.object(mock_http_client, "get"))
    http_get_mock.side_effect = FakeHttpResponseFactory(
        "https://example.com",
        {"foo": "bar"},
        status_code=200,
        headers={"Content-Type": "application/json"},
    )
```

**Parameters**

- **url** (`str`)
- **response_data** (`Any`)
- **status_code** (`int`)
- **headers** (`Optional[dict[str, str]]`)
