Metadata-Version: 2.1
Name: swiftmock
Version: 0.0.1.dev0
Summary: A mock backend for testing swift.
Home-page: https://github.com/canonical/swiftmock
Author: Dan Ryan
Author-email: dan.ryan@canonical.com
License: Apache-2.0
Project-URL: Source Code, https://github.com/canonical/swiftmock
Project-URL: Change Log, https://github.com/canonical/swiftmock/CHANGES.rst
Keywords: openstack,swift,pytest,mock
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Framework :: Pytest
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.6
Description-Content-Type: text/x-rst
Requires-Dist: requests
Requires-Dist: python-swiftclient
Requires-Dist: pytest (>=4.4.0)
Provides-Extra: dev
Requires-Dist: invoke ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: rope ; extra == 'dev'
Provides-Extra: lint
Requires-Dist: black ; extra == 'lint'
Requires-Dist: flake8 ; extra == 'lint'
Requires-Dist: flake8-bugbear ; extra == 'lint'
Requires-Dist: isort ; extra == 'lint'
Requires-Dist: mypy ; extra == 'lint'
Provides-Extra: release
Requires-Dist: parver ; extra == 'release'
Requires-Dist: towncrier ; extra == 'release'
Provides-Extra: tests
Requires-Dist: coverage ; extra == 'tests'
Requires-Dist: pytest-timeout ; extra == 'tests'
Requires-Dist: readme-renderer[md] ; extra == 'tests'
Requires-Dist: twine ; extra == 'tests'

===============================================================================
swiftmock: A mock backend for testing swift.
===============================================================================


🐉 Installation
=================

Install from `PyPI`_:

  ::

    $ pip install swiftmock

.. _PyPI: https://www.pypi.org/project/swiftmock
.. _Github: https://github.com/canonical/swiftmock


🐉 Usage
==========

Importing directly
-------------------

You can use **swiftmock** directly in your code:

.. code:: python

    from swiftmock.swift import MockConnection
    with MockConnection() as conn:
        conn.put_container("fake-container")
        conn.put_object("fake-container", "path/to/object", b"contents")
        header, contents = conn.get_object("fake-container", "path/to/object")
    assert contents == b"contents"


Using with `Pytest`_
---------------------

You can also use this library as a **pytest** plugin.

.. code:: python

    def my_test_using_swift(mock_swift):
        # optional, the mock automatically replaces *swiftclient.client.Connection*
        # so that it automatically returns the mocked instance
        mock_swift.put_container("fake-container")
        with pytest.assert_raises(swiftclient.exceptions.ClientException):
            mock_swift.get_object("fake-container", "non/existent/object")


.. _Pytest: https://pytest.org




