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
Release history Release notifications | RSS feed
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 hashes)
Built Distribution
Close
Hashes for swiftmock-0.0.1.dev0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7aa0dc63445404cc9c811624ed7fab3de23bbf43b8efc9536c7c1b08aee7a173 |
|
MD5 | 0669f1b00f1b2082f75e8fdc6012642f |
|
BLAKE2b-256 | 0d102527edc08959aeec42568f872cfa288e3e98477dd3fe282a695c596834b1 |