How to use get_session method in AutoItDriverServer

Best Python code snippet using AutoItDriverServer_python Github


Full Screen

...78 self.viewmenumodelview.datamodel = SQLAInterface(self.viewmenu_model)79 self.permissionviewmodelview.datamodel = SQLAInterface(self.permissionview_model)80 self.create_db()81 @property82 def get_session(self):83 return self.appbuilder.get_session84 def register_views(self):85 super().register_views()86 def create_db(self):87 try:88 engine = self.get_session.get_bind(mapper=None, clause=None)89 inspector = Inspector.from_engine(engine)90 if "ab_user" not in inspector.get_table_names():91 Base.metadata.create_all(engine)93 super().create_db()95 except Exception as e:96 log.error(c.LOGMSG_ERR_SEC_CREATE_DB.format(str(e)))...

Full Screen

Full Screen Github


Full Screen

...5from nose import SkipTest6from beaker.crypto import has_aes7from beaker.session import Session8from beaker import util9def get_session(**kwargs):10 """A shortcut for creating :class:`Session` instance"""11 options = {}12 options.update(**kwargs)13 return Session({}, **options)14def test_save_load():15 """Test if the data is actually persistent across requests"""16 session = get_session()17 session[u'Suomi'] = u'Kimi Räikkönen'18 session[u'Great Britain'] = u'Jenson Button'19 session[u'Deutchland'] = u'Sebastian Vettel'20 session = get_session( assert u'Suomi' in session23 assert u'Great Britain' in session24 assert u'Deutchland' in session25 assert session[u'Suomi'] == u'Kimi Räikkönen'26 assert session[u'Great Britain'] == u'Jenson Button'27 assert session[u'Deutchland'] == u'Sebastian Vettel'28def test_save_load_encryption():29 """Test if the data is actually persistent across requests"""30 if not has_aes:31 raise SkipTest()32 session = get_session(encrypt_key='666a19cf7f61c64c',33 validate_key='hoobermas')34 session[u'Suomi'] = u'Kimi Räikkönen'35 session[u'Great Britain'] = u'Jenson Button'36 session[u'Deutchland'] = u'Sebastian Vettel'37 session = get_session(, encrypt_key='666a19cf7f61c64c',39 validate_key='hoobermas')40 assert u'Suomi' in session41 assert u'Great Britain' in session42 assert u'Deutchland' in session43 assert session[u'Suomi'] == u'Kimi Räikkönen'44 assert session[u'Great Britain'] == u'Jenson Button'45 assert session[u'Deutchland'] == u'Sebastian Vettel'46def test_decryption_failure():47 """Test if the data fails without the right keys"""48 if not has_aes:49 raise SkipTest()50 session = get_session(encrypt_key='666a19cf7f61c64c',51 validate_key='hoobermas')52 session[u'Suomi'] = u'Kimi Räikkönen'53 session[u'Great Britain'] = u'Jenson Button'54 session[u'Deutchland'] = u'Sebastian Vettel'55 session = get_session(, encrypt_key='asfdasdfadsfsadf',57 validate_key='hoobermas', invalidate_corrupt=True)58 assert u'Suomi' not in session59 assert u'Great Britain' not in session60def test_delete():61 """Test :meth:`Session.delete`"""62 session = get_session()63 session[u'Suomi'] = u'Kimi Räikkönen'64 session[u'Great Britain'] = u'Jenson Button'65 session[u'Deutchland'] = u'Sebastian Vettel'66 session.delete()67 assert u'Suomi' not in session68 assert u'Great Britain' not in session69 assert u'Deutchland' not in session70def test_revert():71 """Test :meth:`Session.revert`"""72 session = get_session()73 session[u'Suomi'] = u'Kimi Räikkönen'74 session[u'Great Britain'] = u'Jenson Button'75 session[u'Deutchland'] = u'Sebastian Vettel'76 session = get_session( del session[u'Suomi']79 session[u'Great Britain'] = u'Lewis Hamilton'80 session[u'Deutchland'] = u'Michael Schumacher'81 session[u'España'] = u'Fernando Alonso'82 session.revert()83 assert session[u'Suomi'] == u'Kimi Räikkönen'84 assert session[u'Great Britain'] == u'Jenson Button'85 assert session[u'Deutchland'] == u'Sebastian Vettel'86 assert u'España' not in session87def test_invalidate():88 """Test :meth:`Session.invalidate`"""89 session = get_session()90 id = session.id91 created = session.created92 session[u'Suomi'] = u'Kimi Räikkönen'93 session[u'Great Britain'] = u'Jenson Button'94 session[u'Deutchland'] = u'Sebastian Vettel'95 session.invalidate()96 assert != id97 assert session.created != created98 assert u'Suomi' not in session99 assert u'Great Britain' not in session100 assert u'Deutchland' not in session101def test_regenerate_id():102 """Test :meth:`Session.regenerate_id`"""103 # new session & save104 session = get_session()105 orig_id = session.id106 session[u'foo'] = u'bar'107 # load session109 session = get_session( # data should still be there111 assert session[u'foo'] == u'bar'112 # regenerate the id113 session.regenerate_id()114 assert != orig_id115 # data is still there116 assert session[u'foo'] == u'bar'117 # should be the new id118 assert '' % in session.request['cookie_out']119 # get a new session before calling save120 bunk_sess = get_session( assert u'foo' not in bunk_sess122 # save it123 # make sure we get the data back125 session = get_session( assert session[u'foo'] == u'bar'127def test_timeout():128 """Test if the session times out properly"""129 session = get_session(timeout=2)130 id = session.id131 created = session.created132 session[u'Suomi'] = u'Kimi Räikkönen'133 session[u'Great Britain'] = u'Jenson Button'134 session[u'Deutchland'] = u'Sebastian Vettel'135 session = get_session(, timeout=2)137 assert == id138 assert session.created == created139 assert session[u'Suomi'] == u'Kimi Räikkönen'140 assert session[u'Great Britain'] == u'Jenson Button'141 assert session[u'Deutchland'] == u'Sebastian Vettel'142 time.sleep(2)143 session = get_session(, timeout=2)144 assert != id145 assert session.created != created146 assert u'Suomi' not in session147 assert u'Great Britain' not in session148 assert u'Deutchland' not in session149def test_cookies_enabled():150 """151 Test if cookies are sent out properly when ``use_cookies``152 is set to ``True``153 """154 session = get_session(use_cookies=True)155 assert 'cookie_out' in session.request156 assert session.request['set_cookie'] == False157 session.domain = ''158 session.path = '/example'159 assert session.request['set_cookie'] == True160 assert '' % in session.request['cookie_out']161 assert '' in session.request['cookie_out']162 assert 'Path=/' in session.request['cookie_out']163 session = get_session(use_cookies=True)164 assert session.request['set_cookie'] == True166 assert '' % in session.request['cookie_out']167 session = get_session(use_cookies=True, session.delete()169 assert session.request['set_cookie'] == True170 assert '' % in session.request['cookie_out']171 assert 'expires=' in session.request['cookie_out']172 # test for secure173 session = get_session(use_cookies=True, secure=True)174 assert 'secure' in session.request['cookie_out']175 # test for httponly176 class ShowWarning(object):177 def __init__(self):178 self.msg = None179 def __call__(self, message, category, filename, lineno, file=None, line=None):180 self.msg = str(message)181 orig_sw = warnings.showwarning182 sw = ShowWarning()183 warnings.showwarning = sw184 session = get_session(use_cookies=True, httponly=True)185 if sys.version_info < (2, 6):186 assert sw.msg == 'Python 2.6+ is required to use httponly'187 else:188 assert 'httponly' in session.request['cookie_out']189 warnings.showwarning = orig_sw190def test_cookies_disabled():191 """192 Test that no cookies are sent when ``use_cookies`` is set to ``False``193 """194 session = get_session(use_cookies=False)195 assert 'set_cookie' not in session.request196 assert 'cookie_out' not in session.request197 assert 'set_cookie' not in session.request199 assert 'cookie_out' not in session.request200 session = get_session(use_cookies=False, assert 'set_cookie' not in session.request202 assert 'cookie_out' not in session.request203 session.delete()204 assert 'set_cookie' not in session.request205 assert 'cookie_out' not in session.request206def test_file_based_replace_optimization():207 """Test the file-based backend with session,208 which includes the 'replace' optimization.209 """210 session = get_session(use_cookies=False, type='file',211 data_dir='./cache')212 session['foo'] = 'foo'213 session['bar'] = 'bar'214 session = get_session(use_cookies=False, type='file',216 data_dir='./cache', assert session['foo'] == 'foo'218 assert session['bar'] == 'bar'219 session['bar'] = 'bat'220 session['bat'] = 'hoho'221 session.namespace.do_open('c', False)223 session.namespace['test'] = 'some test'224 session.namespace.do_close()225 session = get_session(use_cookies=False, type='file',226 data_dir='./cache', session.namespace.do_open('r', False)228 assert session.namespace['test'] == 'some test'229 session.namespace.do_close()230 assert session['foo'] == 'foo'231 assert session['bar'] == 'bat'232 assert session['bat'] == 'hoho'233 # the file has been replaced, so our out-of-session235 # key is gone236 session.namespace.do_open('r', False)237 assert 'test' not in session.namespace238 session.namespace.do_close()239def test_invalidate_corrupt():240 session = get_session(use_cookies=False, type='file',241 data_dir='./cache')242 session['foo'] = 'bar'243 f = open(session.namespace.file, 'w')245 f.write("crap")246 f.close()247 util.assert_raises(248 util.pickle.UnpicklingError,249 get_session,250 use_cookies=False, type='file',251 data_dir='./cache', id=session.id252 )253 session = get_session(use_cookies=False, type='file',254 invalidate_corrupt=True,255 data_dir='./cache',

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run AutoItDriverServer automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?