Merge lp:~camptocamp/oerpscenario/fix-create-db-odoo-8 into lp:oerpscenario

Proposed by Yannick Vaucher @ Camptocamp
Status: Rejected
Rejected by: Yannick Vaucher @ Camptocamp
Proposed branch: lp:~camptocamp/oerpscenario/fix-create-db-odoo-8
Merge into: lp:oerpscenario
Diff against target: 45 lines (+15/-10)
1 file modified
features/environment.py (+15/-10)
To merge this branch: bzr merge lp:~camptocamp/oerpscenario/fix-create-db-odoo-8
Reviewer Review Type Date Requested Status
Leonardo Pistone Needs Fixing
Review via email: mp+231934@code.launchpad.net
To post a comment you must log in.
333. By Yannick Vaucher @ Camptocamp

do log user in before_scenario in order to be able, with a tag @no_login, to execute action without trying to log. It can be useful to repair a database or to create the database before logging in.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

1. you could take the occasion to refactor the original code in

admin_login_password = xxx.get('yyy') or 'admin'

and remove the "if" block

2. the commit message is unclear to me, you mean "do NOT log user in" ?

3. the new commentary sound also a bit obscure but maybe it's only me :)

4. not 'no_login' in -> 'no_login' not in

thanks

review: Needs Fixing
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Unmerged revisions

333. By Yannick Vaucher @ Camptocamp

do log user in before_scenario in order to be able, with a tag @no_login, to execute action without trying to log. It can be useful to repair a database or to create the database before logging in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'features/environment.py'
--- features/environment.py 2013-09-03 10:44:42 +0000
+++ features/environment.py 2014-08-22 17:05:01 +0000
@@ -22,26 +22,31 @@
22 'db_name': database,22 'db_name': database,
23 'openerp_config': server.tools.config,23 'openerp_config': server.tools.config,
24 }24 }
25 # We try to manage default login25
26 # even if there is a sentence to log a given user
27 # Just add options.admin_login_password in your buildout to log from config
28 admin_login_password = server.tools.config.get('admin_login_password')
29 if admin_login_password:
30 ctx.client.login('admin', admin_login_password, database=database)
31 else:
32 ctx.client.login('admin', 'admin', database=database)
3326
3427
35def before_feature(ctx, feature):28def before_feature(ctx, feature):
36 #pdb.set_trace()29 #pdb.set_trace()
37 ctx.data = {}30 ctx.data = {}
3831
39
40# Work around https://github.com/behave/behave/issues/14532# Work around https://github.com/behave/behave/issues/145
41def before_scenario(ctx, scenario):33def before_scenario(ctx, scenario):
42 if not hasattr(ctx, 'data'):34 if not hasattr(ctx, 'data'):
43 ctx.data = {}35 ctx.data = {}
4436 # login if not done only then
37 # this in order to be able to create database first
38 # and / or execute some sql requests
39 if not ctx.client.user and not 'no_login' in scenario.tags:
40 server = ctx.conf['server']
41 database = ctx.conf['db_name']
42 # We try to manage default login
43 # even if there is a sentence to log a given user
44 # Just add options.admin_login_password in your buildout to log from config
45 admin_login_password = server.tools.config.get('admin_login_password')
46 if admin_login_password:
47 ctx.client.login('admin', admin_login_password, database=database)
48 else:
49 ctx.client.login('admin', 'admin', database=database)
4550
46def before_step(ctx, step):51def before_step(ctx, step):
47 #pdb.set_trace()52 #pdb.set_trace()

Subscribers

People subscribed via source and target branches

to all changes: