Skip to main content

RESTful API Testing Suite

Project description

Testing framework for RESTful APIs such as the OpenStack/Rackspace APIs

Travis-CI Status


Stack-In-A-Box is a RESTful API Testing Framework for unit testing applications against the other services with support for OpenStack/Rackspace APIs.


Installation is simple:

pip install stackinabox


  • Enable Python modules to be unit tested against externals services and the OpenStack/Rackspace services (f.e Keystone) in particular in an environment entirely controlled by the unittest.
  • The service should be started/stopped and configured from the setup/teardown methods of the unittest
  • Support both Postive and Negative testing
  • Testing should be easy to do: - you shouldn’t need to know the ins and outs of each service - you should be able to register what you need (f.e keystone, swift) and have it just work
  • should be useable on systems like Travis (
  • should be light on requirements - we don’t want to bloat your testing to fit our needs - if we have many requirements they could interfere with your requirements:w
  • The code being unit-tested should not be able to tell the difference of whether it is working with Stack-In-A-Box or the real thing - the should be nothing special about setting up the test - if you don’t turn on Stack-In-A-Box then the code should be able to call the real thing

Why not use framework X?

I considered a couple frameworks and tools, but they didn’t quite meet the goal.

For instance, mimic ( is a great tool for testing multiple things. However, you have to start/stop it separately from your tests. On the other hand, pretenders ( has a nice framework too, but it doesn’t actually use sockets.

What’s Provided?

It’s a work in progress. Here’s the list of current targets in-order:

  • Keystone v2
  • Keystone v3
  • Swift

Thus far Keystone v2 provides end-points for:

  • Listing tenants
  • Listing users

It also has support in the backend for:

  • tenant (add/remove/enable/disable)
  • users (add/remove/enable/disable, apikey, password)
  • tokens (add/remove, revoke, validate, admin tokens)
  • roles (add, assign)

Working with Frameworks

Stack-In-A-Box does not itself provide a socket interception framework. Out-of-the-box it supports two frameworks:

You can use either one, and you must pull them in via your own test requirements.

Both of these are extremely easy to use as shown in the following examples:


import unittest

import httpretty
import requests

import stackinabox.httpretty
from stackinabox.stack import StackInABox
from import HelloService

class TestHttpretty(unittest.TestCase):

    def setUp(self):
        super(TestHttpretty, self).setUp()

    def tearDown(self):
        super(TestHttpretty, self).tearDown()

    def test_basic(self):

        res = requests.get('http://localhost/')
        self.assertEqual(res.status_code, 200)
        self.assertEqual(res.text, 'Hello')
        assert False


import unittest

import responses
import requests

import stackinabox.responses
from stackinabox.stack import StackInABox
from import HelloService

def test_basic_responses():

    res = requests.get('http://localhost/hello/')
    assert res.status_code == 200
    assert res.text == 'Hello'

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
stackinabox-0.2.tar.gz (10.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page