Merge lp:~diegosarmentero/ubuntuone-client/search-filter into lp:ubuntuone-client
| Status: | Merged |
|---|---|
| Approved by: | Diego Sarmentero on 2012-10-24 |
| Approved revision: | 1352 |
| Merged at revision: | 1350 |
| Proposed branch: | lp:~diegosarmentero/ubuntuone-client/search-filter |
| Merge into: | lp:ubuntuone-client |
| Diff against target: |
507 lines (+324/-1) 14 files modified
contrib/testing/testcase.py (+2/-0) tests/platform/ipc/test_external_interface.py (+9/-0) tests/platform/test_tools.py (+20/-0) tests/syncdaemon/test_files_search.py (+87/-0) tests/syncdaemon/test_fsm.py (+107/-0) ubuntuone/platform/ipc/ipc_client.py (+4/-0) ubuntuone/platform/ipc/linux.py (+6/-0) ubuntuone/platform/ipc/perspective_broker.py (+5/-0) ubuntuone/platform/tools/__init__.py (+5/-0) ubuntuone/syncdaemon/files_search.py (+48/-0) ubuntuone/syncdaemon/filesystem_manager.py (+17/-1) ubuntuone/syncdaemon/interaction_interfaces.py (+6/-0) ubuntuone/syncdaemon/main.py (+3/-0) ubuntuone/syncdaemon/volume_manager.py (+5/-0) |
| To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-client/search-filter |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Mike McCracken (community) | Approve on 2012-10-24 | ||
| Roberto Alsina (community) | 2012-10-22 | Approve on 2012-10-23 | |
|
Review via email:
|
|||
Description of the Change
This will be used from control panel, instead of having the data of the files inside u1 duplicated there, and this will be fix the problems to keep that data up to date, and check if the files are already in the server (as the two bug reports describe).
- 1348. By Diego Sarmentero on 2012-10-22
-
adding missing files
- 1349. By Diego Sarmentero on 2012-10-22
-
delete unnecesary fake
- 1350. By Diego Sarmentero on 2012-10-23
-
removing line for testing purposes
- 1351. By Diego Sarmentero on 2012-10-23
-
docstring fixed
- 1352. By Diego Sarmentero on 2012-10-23
-
fix string
| Mike McCracken (mikemc) wrote : | # |
Hmm, my example test is kind of dumb, since it's pointing out something in the test, not in the method it's testing… I should probably have put it in test_files_
| Mike McCracken (mikemc) wrote : | # |
I've changed my mind.
For reference: I'm OK with matching fuzzy things, and I was mostly concerned with the order in which they appear, I wanted to be sure the least-surprising match showed up first.
However the only example I found where that might happen was if we have a search pattern with a space, and the files list has a pattern with no space that matches that pattern because of our fuzzy changes. In this case, though, when we sort the matching paths at the end of get_paths_
So even though using multiple regexes to control the order of matches is only a little slower in real terms, I can't think of a case in which it's necessary.


I don't really agree with replacing spaces with '.+'.
The old share_links_search does a substring search in just the
basename, while this matches the whole path, which I think is a good
idea.
However, I was expecting this to also be substring search, but you are
replacing spaces in the search string with '.+', which means the
behavior is a little unexpected wrt. spaces in the search text.
Here's a test to be added to test_fsm.py in FSMSearchTestCase that shows what I mean:
def test_get_ paths_by_ pattern_ with_spaces( self): to/a/file/ deep/in/ the/woods/ called/ a file' to/anythingyouw ant-to- defile'
self.fsm. _idx_path = {path: mdid, path2: mdid2} re.escape( 'a file').split('\\ ')) get_paths_ by_pattern( search) by_pattern: ", result
self.assertEqu al(result, expected)
"""Test that spaces in a pattern are handled as expected."""
mdid = 'id'
path = '/my/path/
mdobj = {'server_hash': 'asdqwe123'}
mdid2 = 'id2'
path2 = '/my/path/
mdobj2 = {'server_hash': 'asdqwe456'}
self.fsm.fs = {mdid: mdobj, mdid2: mdobj2}
expected = [path]
# expectations
paths = "(%s|%s)" % ('/my/path/', '/home/')
pattern = paths + ".*/.*%s.*$"
keywords = '.+'.join(
print "keywords:", keywords
search = pattern % keywords
result = self.fsm.
print "result from get_paths_
I would expect "a file" to not match "anythingyouwan t-to-defile" . It
matches both:
Here's what that test prints: to/a/file/ deep/in/ the/woods/ called/ a file id to/a/file/ deep/in/ the/woods/ called/ a file to/anythingyouw ant-to- defile id2 to/anythingyouw ant-to- defile by_pattern: ['/my/path/ to/a/file/ deep/in/ the/woods/ called/ a file', '/my/path/ to/anythingyouw ant-to- defile' ] mmccrack/ Documents/ Canonical/ Source/ test-improve- buildout/ scripts/ devsetup/ parts/ubuntuone -client/ tests/syncdaemo n/test_ fsm.py" , line 4361, in test_get_ paths_by_ pattern_ with_spaces assertEqual( result, expected) mmccrack/ Documents/ Canonical/ Source/ test-improve- buildout/ scripts/ devsetup/ eggs/Twisted- 11.1.0- py2.7-macosx- 10.7-x86_ 64.egg/ twisted/ trial/unittest. py", line 270, in assertEqual trial.unittest. FailTest: not equal: to/a/file/ deep/in/ the/woods/ called/ a file', to/anythingyouw ant-to- defile' ] to/a/file/ deep/in/ the/woods/ called/ a file']
keywords: a.+file
searching through /my/path/
match with p= /my/path/
searching through /my/path/
match with p= /my/path/
result from get_paths_
Traceback (most recent call last):
File "/Users/
self.
File "/Users/
% (msg, pformat(first), pformat(second)))
twisted.
a = ['/my/path/
'/my/path/
b = ['/my/path/