Merge lp:~camptocamp/oerpscenario/fix-find-no-items-lep into lp:oerpscenario

Proposed by Leonardo Pistone
Status: Merged
Merged at revision: 333
Proposed branch: lp:~camptocamp/oerpscenario/fix-find-no-items-lep
Merge into: lp:oerpscenario
Diff against target: 46 lines (+20/-8)
1 file modified
features/steps/dsl.py (+20/-8)
To merge this branch: bzr merge lp:~camptocamp/oerpscenario/fix-find-no-items-lep
Reviewer Review Type Date Requested Status
Nicolas Bessi - Camptocamp (community) Approve
Alexandre Fayolle - camptocamp code review, no tests Approve
Review via email: mp+223431@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

LGTM

thanks

review: Approve (code review, no tests)
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'features/steps/dsl.py'
2--- features/steps/dsl.py 2014-06-17 08:14:33 +0000
3+++ features/steps/dsl.py 2014-06-17 15:59:27 +0000
4@@ -197,6 +197,17 @@
5
6 @step(u'I find a{n:optional}{active_text:optional} "{model_name}" with {domain}')
7 def impl(ctx, n, active_text, model_name, domain):
8+ """
9+ Search with a domain in text format.
10+
11+ The result is stored in ctx.found_item and ctx.found_items as follows:
12+ - if nothing is found, found_item = None
13+ and found_items = RecordList([]), no exception is raised
14+ - if one record is found, found_item = Record(id) and found_items =
15+ RecordList([id])
16+ - if many records are found, found_item = None and found_items =
17+ RecordList(ids)
18+ """
19 # n is there for the english grammar, but not used
20 assert active_text in ('', 'inactive', 'active', 'possibly inactive')
21 Model = model(model_name)
22@@ -208,15 +219,16 @@
23 elif active_text == 'possibly inactive':
24 active = None
25 domain = build_search_domain(ctx, model_name, values, active=active)
26- if domain is not None:
27- ids = Model.search(domain)
28- else:
29- ids = []
30- if len(ids) == 1:
31- ctx.found_item = Model.browse(ids[0])
32- else:
33+
34+ if domain is None:
35 ctx.found_item = None
36- ctx.found_items = Model.browse(ids)
37+ ctx.found_items = erppeek.RecordList(Model, [])
38+ else:
39+ ctx.found_items = Model.browse(domain)
40+ if len(ctx.found_items) == 1:
41+ ctx.found_item = ctx.found_items[0]
42+ else:
43+ ctx.found_item = None
44
45
46 @step(u'I need a{n:optional}{active_text:optional} "{model_name}" with {domain}')

Subscribers

People subscribed via source and target branches

to all changes: