177 |
177 |
assert pub.session_manager.session_class.count() == 2
|
178 |
178 |
|
179 |
179 |
|
180 |
|
def test_session_substitution_variables(pub, user, app):
|
181 |
|
pub.session_manager.session_class.wipe()
|
182 |
|
resp = app.get('/')
|
183 |
|
|
184 |
|
formdef = FormDef()
|
185 |
|
formdef.name = 'foobar'
|
186 |
|
formdef.fields = [fields.CommentField(id='7', label='Hello [session_id]', type='comment')]
|
187 |
|
formdef.store()
|
188 |
|
|
189 |
|
resp = app.get('/foobar/')
|
190 |
|
assert pub.session_manager.session_class.count() == 1
|
191 |
|
session_id = pub.session_manager.session_class.select()[0].id
|
192 |
|
assert 'Hello %s' % session_id in resp.text
|
193 |
|
|
194 |
|
login(app, username='foo', password='foo')
|
195 |
|
assert pub.session_manager.session_class.count() == 2
|
196 |
|
session_id = [x for x in pub.session_manager.session_class.select() if x.id != session_id][0].id
|
197 |
|
resp = app.get('/foobar/')
|
198 |
|
assert 'Hello %s' % session_id in resp.text
|
199 |
|
|
200 |
|
|
201 |
180 |
def test_session_substitution_variables_1st_page_condition(pub, user, app):
|
202 |
181 |
pub.session_manager.session_class.wipe()
|
203 |
182 |
resp = app.get('/')
|
... | ... | |
205 |
184 |
formdef = FormDef()
|
206 |
185 |
formdef.name = 'foobar'
|
207 |
186 |
formdef.fields = [fields.PageField(id='0', label='1st PAGE', type='page',
|
208 |
|
condition={'type': 'python', 'value': 'vars().get("session_id") is not None'}),
|
209 |
|
fields.CommentField(id='7', label='COM1 [session_id]', type='comment'),
|
|
187 |
condition={'type': 'python', 'value': 'vars().get("session_hash_id") is not None'}),
|
210 |
188 |
fields.CommentField(id='10', label='COMHASH1 [session_hash_id]', type='comment'),
|
211 |
189 |
fields.PageField(id='8', label='2nd PAGE', type='page'),
|
212 |
|
fields.CommentField(id='9', label='COM2 [session_id]', type='comment')]
|
|
190 |
fields.CommentField(id='9', label='COM2 [session_hash_id]', type='comment')]
|
213 |
191 |
formdef.store()
|
214 |
192 |
|
215 |
193 |
resp = app.get('/foobar/')
|
216 |
194 |
assert pub.session_manager.session_class.count() == 1
|
217 |
195 |
session = pub.session_manager.session_class.select()[0]
|
218 |
|
assert 'COM1 %s' % session.id in resp.text
|
219 |
196 |
assert 'COMHASH1 %s' % session.get_substitution_variables().get('session_hash_id') in resp.text
|
220 |
197 |
|
221 |
198 |
|