Skip to main content

A mock backend for testing swift.

Project description

🐉 Installation

Install from PyPI:

$ pip install swiftmock

🐉 Usage

Importing directly

You can use swiftmock directly in your code:

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.

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swiftmock-0.0.1.dev0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

swiftmock-0.0.1.dev0-py2.py3-none-any.whl (17.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file swiftmock-0.0.1.dev0.tar.gz.

File metadata

  • Download URL: swiftmock-0.0.1.dev0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for swiftmock-0.0.1.dev0.tar.gz
Algorithm Hash digest
SHA256 fe007a229499765195d110bf7b82802ea96a3eeee555d6c70002cd43c88aafc0
MD5 a738642d84c669d3e338d08da42d2c2e
BLAKE2b-256 aa0adf2205305cf766fc49d92efddf6749ed7b3d9c3c759cf8e21d1deea8fb5f

See more details on using hashes here.

File details

Details for the file swiftmock-0.0.1.dev0-py2.py3-none-any.whl.

File metadata

  • Download URL: swiftmock-0.0.1.dev0-py2.py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for swiftmock-0.0.1.dev0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7aa0dc63445404cc9c811624ed7fab3de23bbf43b8efc9536c7c1b08aee7a173
MD5 0669f1b00f1b2082f75e8fdc6012642f
BLAKE2b-256 0d102527edc08959aeec42568f872cfa288e3e98477dd3fe282a695c596834b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page