Skip to main content

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

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

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.2.0.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file testinstances-0.2.0.tar.gz.

File metadata

File hashes

Hashes for testinstances-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7c2046cb92926c7cd5b9d66931e0fb181cc6b3f5d9278bdf1a75291dd9a91550
MD5 a59471bec489ece19b37f6741444be62
BLAKE2b-256 3f1ba3327a41cabb8f7e4d7bd09d98506d869038391cfbe9a7f03595554e2bad

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