Merge lp:~fginther/uci-engine/field-separator into lp:uci-engine

Proposed by Francis Ginther
Status: Merged
Approved by: Francis Ginther
Approved revision: 912
Merged at revision: 911
Proposed branch: lp:~fginther/uci-engine/field-separator
Merge into: lp:uci-engine
Diff against target: 101 lines (+72/-2)
2 files modified
tests/test_webui.py (+69/-0)
webui/tickets/static/tickets/webuiforms.js (+3/-2)
To merge this branch: bzr merge lp:~fginther/uci-engine/field-separator
Reviewer Review Type Date Requested Status
Paul Larson Approve
Review via email: mp+245032@code.launchpad.net

Commit message

Use a regex for splitting Sources and MPs and allow any whitespace as a separator.

Description of the change

Use a regex for splitting Sources and MPs and allow any whitespace as a separator.

This implements https://app.asana.com/0/20835902057994/21373859714237.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Looks good, +1

review: Approve
Revision history for this message
Ubuntu CI Bot (uci-bot) wrote :

Attempt to merge into lp:uci-engine failed due to conflicts:

text conflict in tests/test_webui.py

911. By Francis Ginther

Merge trunk.

912. By Francis Ginther

Update the test ticket title.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_webui.py'
2--- tests/test_webui.py 2014-12-16 20:49:10 +0000
3+++ tests/test_webui.py 2014-12-18 21:37:26 +0000
4@@ -186,6 +186,68 @@
5 'Source Packages or Merge Proposals must be supplied',
6 error.text)
7
8+ def test_create_ticket_with_whitespace_and_comma_separator(self):
9+ # Create a ticket using various whitespace and commas as the separator.
10+ # Includes multiple and trailing whitespace and commas
11+ go_to('/create')
12+ wait_for(get_element, tag='form')
13+
14+ # Submit the form with the required fields.
15+ title = get_element_by_css('input[name="title"]')
16+ write_textfield(title, 'Testing With Whitespace and Commas')
17+ landers = get_element_by_css('input[name="landers"]')
18+ write_textfield(landers, 'foo@bar.com')
19+ test_notes = get_element_by_css('textarea[name="test_notes"]')
20+ write_textfield(test_notes, 'test this')
21+ sources = get_element_by_css('textarea[name="sources"]')
22+ write_textfield(sources, 'foo, , , bar\nbang , ')
23+ mps = get_element_by_css('textarea[name="merge_proposals"]')
24+ write_textfield(
25+ mps,
26+ 'https://code.launchpad.net/~x/foo/a_branch/+merge/1, '
27+ 'https://code.launchpad.net/~x/foo/a_branch/+merge/2\n'
28+ 'https://code.launchpad.net/~x/baz/a_branch/+merge/3,')
29+ submit = get_element_by_css('input[type="submit"]')
30+ click_button(submit, wait=True)
31+
32+ # Redirects to the ticket page where sources & MPs were combined
33+ # as subtickets. Sources mentioned only in MPs are created.
34+ ticket_title = wait_for(get_element, tag='h2')
35+ self.assertEqual('Testing With Whitespace and Commas',
36+ ticket_title.text)
37+ subtickets = get_elements_by_css('table.subticket')
38+ self.assertEqual(
39+ [['Source: foo',
40+ 'Status: -',
41+ 'Step: New',
42+ 'Current version: Not available',
43+ 'MPs: https://code.launchpad.net/~x/foo/a_branch/+merge/1',
44+ 'https://code.launchpad.net/~x/foo/a_branch/+merge/2',
45+ 'Artifacts:',
46+ 'Conflicts:'],
47+ ['Source: bar',
48+ 'Status: -',
49+ 'Step: New',
50+ 'Current version: Not available',
51+ 'MPs:',
52+ 'Artifacts:',
53+ 'Conflicts:'],
54+ ['Source: bang',
55+ 'Status: -',
56+ 'Step: New',
57+ 'Current version: Not available',
58+ 'MPs:',
59+ 'Artifacts:',
60+ 'Conflicts:'],
61+ ['Source: baz',
62+ 'Status: -',
63+ 'Step: New',
64+ 'Current version: Not available',
65+ 'MPs: https://code.launchpad.net/~x/baz/a_branch/+merge/3',
66+ 'Artifacts:',
67+ 'Conflicts:']],
68+ [s.text.splitlines() for s in subtickets])
69+
70 def test_edit_ticket(self):
71 # Edit a ticket via WebUI form.
72 go_to('/')
73@@ -298,6 +360,13 @@
74 'MPs:',
75 'Artifacts:',
76 'Conflicts:'],
77+ ['Source: bang',
78+ 'Status: -',
79+ 'Step: New',
80+ 'Current version: Not available',
81+ 'MPs:',
82+ 'Artifacts:',
83+ 'Conflicts:'],
84 ['Source: baz',
85 'Status: -',
86 'Step: New',
87
88=== modified file 'webui/tickets/static/tickets/webuiforms.js'
89--- webui/tickets/static/tickets/webuiforms.js 2014-12-16 19:22:27 +0000
90+++ webui/tickets/static/tickets/webuiforms.js 2014-12-18 21:37:26 +0000
91@@ -39,8 +39,9 @@
92 * @method _mangleFormSources
93 */
94 _mangleFormSources: function (form_data) {
95- var sources_list = form_data['sources'].split('\n');
96- var mp_list = form_data['merge_proposals'].split('\n');
97+ var re = /[\s,]+/g
98+ var sources_list = form_data['sources'].split(re);
99+ var mp_list = form_data['merge_proposals'].split(re);
100 delete form_data['sources'];
101 delete form_data['merge_proposals'];
102

Subscribers

People subscribed via source and target branches