Managed test instances for integration tests
Project description
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 def 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 def TestSomeJunk(unittest.TestCase): @classmethod def setUpClass(cls): # Set up an instance on port 12345 cls.mongo = MongInstance(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')
Roadmap
New Instance Kinds
Kafka
Zookeeper
Documentation and ReadTheDocs
Travis-CI
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
testinstances-0.1.1.tar.gz
(5.1 kB
view details)
File details
Details for the file testinstances-0.1.1.tar.gz
.
File metadata
- Download URL: testinstances-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aed8ed902b61379fb6fe8ce46108b9c3f394c8c3e1820190a972f09857d5762 |
|
MD5 | fa3d75e3fa3c30435830cf38444624ad |
|
BLAKE2b-256 | db7483ec6e33599e8fed2c89dc8a1930706058a9aa2a25c84802c893a2c39ed2 |