def mock_circlecore_context(): with tempfile.TemporaryDirectory('cc_') as tmp_dir: assert os.path.exists(tmp_dir) assert not os.path.exists(os.path.join(tmp_dir, 'metadata.sqlite3')) metadata_db_engine = sqlalchemy.create_engine( 'sqlite:///' + os.path.join(tmp_dir, 'metadata.sqlite3'), poolclass=NullPool) MetaDataSession.configure(bind=metadata_db_engine) # empty MetaDataBase.metadata.create_all(metadata_db_engine) # make my CcInfo with MetaDataSession.begin(): my_cc_info = CcInfo(display_name='My CircleCore', myself=True, work='') my_cc_info.uuid = generate_uuid(model=CcInfo) MetaDataSession.add(my_cc_info) yield metadata_db_engine, tmp_dir MetaDataBase.metadata.drop_all(metadata_db_engine) MetaDataSession.remove()
def _call(*args): from circle_core.models import MetaDataSession MetaDataSession.remove() return runner.invoke( cli_entry, ['-c', './tests/circle_core.ini', 'invitation'] + list(args))