Merge lp:~diegosarmentero/ubuntuone-client/case-insensitive-search into lp:ubuntuone-client

Proposed by Diego Sarmentero on 2012-11-02
Status: Merged
Approved by: Diego Sarmentero on 2012-11-05
Approved revision: 1358
Merged at revision: 1358
Proposed branch: lp:~diegosarmentero/ubuntuone-client/case-insensitive-search
Merge into: lp:ubuntuone-client
Diff against target: 42 lines (+20/-1)
2 files modified
tests/syncdaemon/test_fsm.py (+19/-0)
ubuntuone/syncdaemon/filesystem_manager.py (+1/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-client/case-insensitive-search
Reviewer Review Type Date Requested Status
Michał Karnicki (community) Approve on 2012-11-05
dobey (community) 2012-11-02 Approve on 2012-11-02
Review via email: mp+132703@code.launchpad.net

Commit Message

- Allow case insensitive search (LP: #1073664).

To post a comment you must log in.
dobey (dobey) wrote :

11 + path = '/my/path/to/file_test'

While I understand that these are dummy data, I still don't like the fact that we have '/path/to/foo' in tests, when there is no obvious distinction in each individual test between what may hit the disk, and what definitely won't.

review: Approve
Michał Karnicki (karni) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_fsm.py'
2--- tests/syncdaemon/test_fsm.py 2012-10-22 13:31:02 +0000
3+++ tests/syncdaemon/test_fsm.py 2012-11-02 13:53:20 +0000
4@@ -4339,6 +4339,25 @@
5 result = self.fsm.get_paths_by_pattern(search)
6 self.assertEqual(result, expected)
7
8+ def test_get_paths_by_pattern_case_insensitive(self):
9+ """Check that we obtain the files that correspond to the filter."""
10+ mdid = 'id'
11+ path = '/my/path/to/file_test'
12+ mdobj = {'server_hash': 'asdqwe123'}
13+ mdid2 = 'id2'
14+ path2 = '/my/path/to/my_photos'
15+ mdobj2 = {'server_hash': 'asdqwe456'}
16+ self.fsm._idx_path = {path: mdid, path2: mdid2}
17+ self.fsm.fs = {mdid: mdobj, mdid2: mdobj2}
18+ expected = ['/my/path/to/file_test']
19+ # expectations
20+ paths = "(%s|%s)" % ('/my/path/', '/home/')
21+ pattern = paths + ".*/.*%s.*$"
22+ keywords = '.+'.join(re.escape('FILE').split('\\ '))
23+ search = pattern % keywords
24+ result = self.fsm.get_paths_by_pattern(search)
25+ self.assertEqual(result, expected)
26+
27 def test_get_paths_by_pattern_valid_folders(self):
28 """Search for the pattern in the valid folders."""
29 mdid = 'id'
30
31=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
32--- ubuntuone/syncdaemon/filesystem_manager.py 2012-10-25 17:28:03 +0000
33+++ ubuntuone/syncdaemon/filesystem_manager.py 2012-11-02 13:53:20 +0000
34@@ -1366,7 +1366,7 @@
35
36 def get_paths_by_pattern(self, search):
37 """Return a list of paths that match the pattern."""
38- pattern = re.compile(search)
39+ pattern = re.compile(search, re.IGNORECASE)
40
41 def _get_matching():
42 """Find the paths that match"""

Subscribers

People subscribed via source and target branches