> ## Documentation Index
> Fetch the complete documentation index at: https://www.getmaxim.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MockWriter

> Mock Writer functionality for Tests integration.

[View module source on GitHub](https://github.com/maximhq/maxim-py/blob/main/maxim/tests/mock_writer.py)

Mock writer for testing purposes.

This module provides a mock implementation of [LogWriter](/sdk/python/references/logger/writer) that captures
logs in memory for testing purposes.

## [MockLogWriter](/sdk/python/references/tests/mock_writer)

```python theme={null}
class MockLogWriter()
```

Mock implementation of [LogWriter](/sdk/python/references/logger/writer) for testing.

This class captures all logs and commands in memory, allowing tests
to verify what was logged without making actual API calls.

#### \_\_init\_\_

```python theme={null}
def __init__(config: LogWriterConfig)
```

Initialize a [MockLogWriter](/sdk/python/references/tests/mock_writer) instance.

**Arguments**:

| Name     | Description                                                              |
| -------- | ------------------------------------------------------------------------ |
| `config` | Configuration for the [LogWriter](/sdk/python/references/logger/writer). |

#### repository\_id

```python theme={null}
@property
def repository_id()
```

Get the repository ID.

#### commit

```python theme={null}
def commit(log: CommitLog)
```

Mock commit that stores the log instead of queuing it.

**Arguments**:

| Name  | Description                                                                  |
| ----- | ---------------------------------------------------------------------------- |
| `log` | [CommitLog](/sdk/python/references/logger/components/types) object to store. |

#### flush

```python theme={null}
def flush(is_sync=False)
```

Mock flush that moves queued logs to flushed logs.

**Arguments**:

| Name      | Description                                       |
| --------- | ------------------------------------------------- |
| `is_sync` | Whether to flush synchronously (ignored in mock). |

#### flush\_commit\_logs

```python theme={null}
def flush_commit_logs(is_sync=False)
```

Mock flush for commit logs only.

#### flush\_upload\_attachment\_logs

```python theme={null}
def flush_upload_attachment_logs(is_sync=False)
```

Mock flush for upload attachment logs only.

#### cleanup

```python theme={null}
def cleanup(is_sync=False)
```

Mock cleanup that flushes remaining logs.

**Arguments**:

| Name      | Description                                         |
| --------- | --------------------------------------------------- |
| `is_sync` | Whether to cleanup synchronously (ignored in mock). |

#### get\_all\_logs

```python theme={null}
def get_all_logs() -> list[CommitLog]
```

Get all logs (committed, flushed, and uploaded).

#### get\_committed\_logs

```python theme={null}
def get_committed_logs()
```

Get only committed logs.

#### get\_flushed\_logs

```python theme={null}
def get_flushed_logs()
```

Get only flushed logs.

#### get\_uploaded\_attachments

```python theme={null}
def get_uploaded_attachments()
```

Get only uploaded attachment logs.

#### get\_logs\_by\_action

```python theme={null}
def get_logs_by_action(action)
```

Get logs filtered by action type.

#### get\_logs\_by\_entity\_action

```python theme={null}
def get_logs_by_entity_action(entity, action)
```

Get logs filtered by entity and action type.

#### get\_logs\_by\_entity

```python theme={null}
def get_logs_by_entity(entity)
```

Get logs filtered by entity type.

#### get\_logs\_by\_entity\_and\_action

```python theme={null}
def get_logs_by_entity_and_action(entity, action)
```

Get logs filtered by entity and action type.

#### get\_logs\_by\_entity\_id

```python theme={null}
def get_logs_by_entity_id(entity_id)
```

Get logs filtered by entity ID.

#### clear\_logs

```python theme={null}
def clear_logs()
```

Clear all stored logs.

#### assert\_log\_count

```python theme={null}
def assert_log_count(expected_count)
```

Assert the total number of logs.

#### assert\_entity\_action\_count

```python theme={null}
def assert_entity_action_count(entity, action, expected_count)
```

Assert the number of logs for a specific entity and action.

#### assert\_action\_count

```python theme={null}
def assert_action_count(action, expected_count)
```

Assert the number of logs for a specific action.

#### assert\_entity\_count

```python theme={null}
def assert_entity_count(entity, expected_count)
```

Assert the number of logs for a specific entity.

#### print\_logs\_summary

```python theme={null}
def print_logs_summary()
```

Print a summary of all captured logs for debugging.
