Example #1
0
class CubeManagerTestCase(TestCase):
    def setUp(self):
        super(CubeManagerTestCase, self).setUp()
        path = os.path.join(FIXTURE_PATH, 'models')
        self.fixture_mgr = JSONCubeManager(self.engine, path)

    def test_list_cubes(self):
        cubes = list(self.fixture_mgr.list_cubes())
        assert len(cubes) == 2, cubes

    def test_has_cube(self):
        assert self.fixture_mgr.has_cube('cra')
        assert not self.fixture_mgr.has_cube('cro')

    def test_get_model(self):
        model = self.fixture_mgr.get_cube_model('cra')
        assert 'dimensions' in model

    @raises(BabbageException)
    def test_get_model_doesnt_exist(self):
        self.fixture_mgr.get_cube_model('cro')

    def test_get_cube(self):
        cube = self.fixture_mgr.get_cube('cra')
        assert isinstance(cube, Cube)

    @raises(BabbageException)
    def test_get_cube_doesnt_exist(self):
        self.fixture_mgr.get_cube('cro')
Example #2
0
class CubeManagerTestCase(TestCase):

    def setUp(self):
        super(CubeManagerTestCase, self).setUp()
        path = os.path.join(FIXTURE_PATH, 'models')
        self.fixture_mgr = JSONCubeManager(self.engine, path)

    def test_list_cubes(self):
        cubes = list(self.fixture_mgr.list_cubes())
        assert len(cubes) == 2, cubes

    def test_has_cube(self):
        assert self.fixture_mgr.has_cube('cra')
        assert not self.fixture_mgr.has_cube('cro')

    def test_get_model(self):
        model = self.fixture_mgr.get_cube_model('cra')
        assert 'dimensions' in model

    @raises(BabbageException)
    def test_get_model_doesnt_exist(self):
        self.fixture_mgr.get_cube_model('cro')

    def test_get_cube(self):
        cube = self.fixture_mgr.get_cube('cra')
        assert isinstance(cube, Cube)

    @raises(BabbageException)
    def test_get_cube_doesnt_exist(self):
        self.fixture_mgr.get_cube('cro')
Example #3
0
 def setUp(self):
     super(CubeManagerTestCase, self).setUp()
     path = os.path.join(FIXTURE_PATH, 'models')
     self.mgr = JSONCubeManager(self.engine, path)
     self.cra_table = load_csv('cra.csv')
     configure_api(self.app, self.mgr)
Example #4
0
 def setUp(self):
     super(CubeManagerTestCase, self).setUp()
     path = os.path.join(FIXTURE_PATH, 'models')
     self.fixture_mgr = JSONCubeManager(self.engine, path)
Example #5
0
 def setUp(self):
     super(CubeManagerTestCase, self).setUp()
     path = os.path.join(FIXTURE_PATH, 'models')
     self.fixture_mgr = JSONCubeManager(self.engine, path)
from flask import Flask
from os.path import join, dirname
from sqlalchemy import create_engine
from babbage.manager import JSONCubeManager
from babbage.api import configure_api
from flask_debugtoolbar import DebugToolbarExtension

app = Flask('demo')
engine = create_engine('sqlite:///' + dirname(__file__) + '/cubes.sqlite',
                       echo=True)

app.debug = True
app.config['SECRET_KEY'] = '<replace with a secret key>'
app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False

models_directory = join(dirname(__file__), 'models')
manager = JSONCubeManager(engine, models_directory)
blueprint = configure_api(app, manager)
app.register_blueprint(blueprint, url_prefix='/api/babbage')
toolbar = DebugToolbarExtension(app)

if __name__ == '__main__':
    app.run()