Make Integration Tests Easier
testinstances is a set of managed instance wrappers to make integration testing with redis and mongodb easier. If you have the binaries on your path, it can handle creating and destroying sandboxed instances for you to test with.
Examples
The API is straightforward and easily embedeed in setup/teardown functions. It also automatically returns a connection to the instance.:
import unittest
from testinstances import RedisInstance
class TestSomeJunk(unittest.TestCase):
def setUp(self):
# Set up an instance on port 12345
self.redis = RedisInstance(12345)
def tearDown(self):
self.redis.terminate()
def test_stuff(self):
self.redis.conn.set('foo', 'bar')
self.assertEqual(self.redis.conn.get('foo'), 'bar')
Or, if you wanted to be fancy and avoid the process creation/termination cost for every test case:
import unittest
from testinstances import MongoInstance
class TestSomeJunk(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Set up an instance on port 12345
cls.mongo = MongoInstance(12345)
@classmethod
def tearDownClass(cls):
cls.mongo.terminate()
def setUp(self):
# All instance types implement ``flush``
self.mongo.flush()
def test_stuff(self):
collection = self.mongo.conn['someDB']['someCollection']
collection.insert({'foo': 'bar'})
self.assertEqual(collection.find({'foo': 'bar'}).next()['foo'], 'bar')
Developing
To run the tests you need to install all of the databases the tests run:
For Debian/Ubuntu:
$ sudo apt-get install redis-server mongodb-server
For OSX:
$ sudo brew install redis mongodb
Then you just run tox.
Roadmap
New Instance Kinds
Kafka
Zookeeper
Documentation and ReadTheDocs
Travis-CI
Metadata
Release files for testinstances 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| testinstances-0.3.0.tar.gz | 6.7 kB | Without provenance | Details for testinstances-0.3.0.tar.gz |
Release files / testinstances-0.3.0.tar.gz
| Download URL | testinstances-0.3.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
410444037181e49727b1fb744d21263249b00393a146b2c7c1b9662c1f4f4a0c
|
|
BLAKE2b-256 checksum How to use checksums |
e717a852428d67b045223598f559572c4c50d725de267f6f7ce3a94f986f0e6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for testinstances 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.