<commit_before>============
 Eve-Mocker
============

Mocking tool for `Eve powered REST API <http://python-eve.org>`_, based on the excellent `HTTPretty <http://falcao.it/HTTPretty>`_, aimed to be used in your unit tests, when you rely on an Eve API.

Features
========

Eve-Mocker doesn't try to replicate every Eve features, by design, it doesn't need any Eve settings files, doesn't support schema validation and more advanced features. Don't hesitate to contribute if you need more complex features.

* Everything is stored in memory (``self.items``)
* Support all methods except HEAD requests
* Handle ETags, and always return meaningful status code, like Eve.
* No need to change your code for testing, HTTPretty does everything for you, it works well with `requests <http://www.python-requests.org>`_.


Installing
==========

(soon to be released on pypy.)

.. code-block::

    $ pip install eve-mocker


Usage
=====

You should read `HTTPretty <http://falcao.it/HTTPretty>`_ documentation before starting.

Here is a basic example:

.. code-block:: python

    from httpretty import HTTPretty
    import requests

    HTTPretty.enable()
    EveMocker("http://myapi.com/api/")
    
    response = requests.get("http://myapi.com/api/mymodel")
    assert response.status_code == 200
    assert response.json() == {"_items": []}

    HTTPretty.disable()


Alternatively, you use ``EveMocker`` within a context manager, and it will automatically call ``HTTPretty.enable()`` and ``HTTPretty.disable()``.

.. code-block:: python

    from eve_mocker import EveMocker
    import requests

    with EveMocker("http://myapi.com/api/"):
        response = requests.get("http://myapi.com/api/mymodel")
        assert response.status_code == 200
        assert response.json() == {"_items": []}<commit_msg>README fix<commit_after>============
 Eve-Mocker
============

Mocking tool for `Eve powered REST API <http://python-eve.org>`_, based on the excellent `HTTPretty <http://falcao.it/HTTPretty>`_, aimed to be used in your unit tests, when you rely on an Eve API.

Features
========

Eve-Mocker doesn't try to replicate every Eve features, by design, it doesn't need any Eve settings files, doesn't support schema validation and more advanced features. Don't hesitate to contribute if you need more complex features.

* Everything is stored in memory (``self.items``)
* Support all methods except HEAD requests
* Handle ETags, and always return meaningful status code, like Eve.
* No need to change your code for testing, HTTPretty does everything for you, it works well with `requests <http://www.python-requests.org>`_.


Installing
==========

(soon to be released on pypy.)

.. code-block::

    $ pip install eve-mocker


Usage
=====

You should read `HTTPretty <http://falcao.it/HTTPretty>`_ documentation before starting.

Here is a basic example:

.. code-block:: python

    from httpretty import HTTPretty
    import requests

    HTTPretty.enable()
    EveMocker("http://myapi.com/api/")
    
    response = requests.get("http://myapi.com/api/mymodel/")
    assert response.status_code == 200
    assert response.json() == {"_items": []}

    HTTPretty.disable()


Alternatively, you use ``EveMocker`` within a context manager, and it will automatically call ``HTTPretty.enable()`` and ``HTTPretty.disable()``.

.. code-block:: python

    from eve_mocker import EveMocker
    import requests

    with EveMocker("http://myapi.com/api/"):
        response = requests.get("http://myapi.com/api/mymodel/")
        assert response.status_code == 200
        assert response.json() == {"_items": []}
{'fraction_non_alphanumeric': 0.13529248683116163, 'fraction_numerical': 0.0033268644302744664, 'mean_word_length': 3.8106666666666666, 'pattern_counts': {'":': 4, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4953276', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1021, 'n_words': 373}