def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine("sqlite://") from mediapublic.models import Base, Users DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: model = Users(first="Joe", last="Test") DBSession.add(model)
def setUp(self): self.config = testing.setUp() from sqlalchemy import create_engine engine = create_engine('sqlite://') from mediapublic.models import ( Base, Users, ) DBSession.configure(bind=engine) Base.metadata.create_all(engine) with transaction.manager: model = Users(first='Joe', last='Test') DBSession.add(model)
from mediapublic.models import DBSession, Base # This is weird, and I'm sorry, but you need to curry in the INI file to # configure the service config_path = os.path.join(os.path.dirname(__file__), 'gabbi.ini'), try: # delete the old DB to start fresh os.remove(os.path.join(os.path.dirname(__file__), 'mediapublic.sqlite')) except: # it may not exist, whatever pass settings = get_appsettings(config_path) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) load_app = functools.partial(get_app, config_path, name='main') # By convention the YAML files are put in a directory named # "gabbits" that is in the same directory as the Python test file. TESTS_DIR = 'gabbits' def load_tests(loader, tests, pattern): """Provide a TestSuite to the discovery process.""" test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR) return driver.build_tests( test_dir, loader,
from mediapublic.models import DBSession, Base # This is weird, and I'm sorry, but you need to curry in the INI file to # configure the service config_path = os.path.join(os.path.dirname(__file__), 'gabbi.ini'), try: # delete the old DB to start fresh os.remove(os.path.join(os.path.dirname(__file__), 'mediapublic.sqlite')) except: # it may not exist, whatever pass settings = get_appsettings(config_path) engine = engine_from_config(settings, 'sqlalchemy.') DBSession.configure(bind=engine) Base.metadata.create_all(engine) load_app = functools.partial(get_app, config_path, name='main') # By convention the YAML files are put in a directory named # "gabbits" that is in the same directory as the Python test file. TESTS_DIR = 'gabbits' def load_tests(loader, tests, pattern): """Provide a TestSuite to the discovery process.""" test_dir = os.path.join(os.path.dirname(__file__), TESTS_DIR) return driver.build_tests(test_dir, loader, intercept=load_app,
def tearDown(self): DBSession.remove() testing.tearDown()