def test_component(self): self.app = Flask('alchemist.tests.a') with settings(self.app, COMPONENTS=['alchemist.tests.a.b']): alchemist.configure(self.app) assert self.app.config.get('B_SETTING', 1) assert self.app.config.get('A_SETTING', 5)
def setup(self): utils.unload_modules('alchemist') self.app = Flask('alchemist.tests.a') self.context = self.app.app_context() self.context.push() alchemist.configure(self.app)
def test_not(self): old = sys.argv sys.argv = ['alchemist', 'load', '../../test.py'] alchemist.configure(self.app) assert not self.app.config['TESTING'] sys.argv = old
def test_alchemist(self): old = sys.argv sys.argv = ['alchemist', 'test'] alchemist.configure(self.app) assert self.app.config['TESTING'] sys.argv = old
def test_unittest(self): old = sys.argv sys.argv = ['python', 'setup.py', 'test'] alchemist.configure(self.app) assert self.app.config['TESTING'] sys.argv = old
def test_nose(self): old = sys.argv sys.argv = ['nosetests'] alchemist.configure(self.app) assert self.app.config['TESTING'] sys.argv = old
def test_missing_project(self): """ Should succeed and not raise if the project does not contain a settings file. """ self.app = Flask('alchemist') with settings(self.app): alchemist.configure(self.app)
def test_project_as_component(self): """ Should not merge the project settings in twice even if it is listed in the COMPONENTS array. """ self.app = Flask('alchemist.tests.a') components = ['alchemist.tests.a.b', 'alchemist.tests.a'] with settings(self.app, COMPONENTS=components): alchemist.configure(self.app) assert self.app.config.get('B_SETTING', 1) assert self.app.config.get('A_SETTING', 5)
def test_project_env(self): """ Should override settings from the file specified in the <project>_SETTINGS_MODULE environ variable. """ filename = path.join(path.dirname(__file__), '../a/b/settings.py') os.environ['TESTS_A_SETTINGS_MODULE'] = filename self.app = Flask('alchemist.tests.a') with settings(self.app): alchemist.configure(self.app) assert self.app.config.get('B_SETTING', 1) assert self.app.config.get('A_SETTING', 5) del os.environ['TESTS_A_SETTINGS_MODULE']
def test_context(self): utils.unload_modules('alchemist') from alchemist.commands import Shell shell = Shell() self.app = Flask('alchemist.tests.a') self.context = self.app.app_context() with self.context: alchemist.configure(self.app) context = shell.make_context() assert 'db' in context assert 'session' in context assert 'Entity' in context
def test_pipe(self): utils.unload_modules('alchemist') self.app = Flask('alchemist.tests.a') self.context = self.app.app_context() with self.context: alchemist.configure(self.app) stdin = sys.stdin sys.stdin = io.StringIO('print(Entity)\nprint(session)') capture = py.io.StdCapture(out=True, in_=False) self._run(['shell', '--pipe']) out, err = capture.done() text = ("<class 'alchemist.tests.a.models.Entity'>\n" "<Session(bind=Engine(sqlite:///:memory:))>\n") assert text == out.read() sys.stdin = stdin
from flask import Flask import alchemist import alchemist_armet application = Flask(__package__) # Configure the application object. alchemist.configure(application) alchemist_armet.configure(application) # @application.route('/') # def index(): # return 'text on the screen'
def setup(self): self.app = Flask('alchemist') self.app.config['COMPONENTS'] = ['alchemist'] alchemist.configure(self.app)
def setup(self): self.app = Flask('alchemist.tests.a') self.context = self.app.app_context() self.context.push() alchemist.configure(self.app)
def test_project(self): self.app = Flask('alchemist.tests.a') with settings(self.app): alchemist.configure(self.app) assert self.app.config.get('A_SETTING', 1)