Merge lp://qastaging/~diegosarmentero/ubuntuone-client/search-filter into lp://qastaging/ubuntuone-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 1352
Merged at revision: 1350
Proposed branch: lp://qastaging/~diegosarmentero/ubuntuone-client/search-filter
Merge into: lp://qastaging/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://qastaging/~diegosarmentero/ubuntuone-client/search-filter
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+130862@code.qastaging.launchpad.net

Commit message

- Search and filter for u1 files (LP: #1056189, #1056197).

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).

To post a comment you must log in.
1348. By Diego Sarmentero

adding missing files

1349. By Diego Sarmentero

delete unnecesary fake

1350. By Diego Sarmentero

removing line for testing purposes

1351. By Diego Sarmentero

docstring fixed

Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
1352. By Diego Sarmentero

fix string

Revision history for this message
Mike McCracken (mikemc) wrote :

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):
        """Test that spaces in a pattern are handled as expected."""
        mdid = 'id'
        path = '/my/path/to/a/file/deep/in/the/woods/called/a file'
        mdobj = {'server_hash': 'asdqwe123'}
        mdid2 = 'id2'
        path2 = '/my/path/to/anythingyouwant-to-defile'
        mdobj2 = {'server_hash': 'asdqwe456'}
        self.fsm._idx_path = {path: mdid, path2: mdid2}
        self.fsm.fs = {mdid: mdobj, mdid2: mdobj2}
        expected = [path]
        # expectations
        paths = "(%s|%s)" % ('/my/path/', '/home/')
        pattern = paths + ".*/.*%s.*$"
        keywords = '.+'.join(re.escape('a file').split('\\ '))
        print "keywords:", keywords
        search = pattern % keywords
        result = self.fsm.get_paths_by_pattern(search)
        print "result from get_paths_by_pattern:", result
        self.assertEqual(result, expected)

I would expect "a file" to not match "anythingyouwant-to-defile". It
matches both:

Here's what that test prints:
keywords: a.+file
searching through /my/path/to/a/file/deep/in/the/woods/called/a file id
match with p= /my/path/to/a/file/deep/in/the/woods/called/a file
searching through /my/path/to/anythingyouwant-to-defile id2
match with p= /my/path/to/anythingyouwant-to-defile
result from get_paths_by_pattern: ['/my/path/to/a/file/deep/in/the/woods/called/a file', '/my/path/to/anythingyouwant-to-defile']
Traceback (most recent call last):
  File "/Users/mmccrack/Documents/Canonical/Source/test-improve-buildout/scripts/devsetup/parts/ubuntuone-client/tests/syncdaemon/test_fsm.py", line 4361, in test_get_paths_by_pattern_with_spaces
    self.assertEqual(result, expected)
  File "/Users/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
    % (msg, pformat(first), pformat(second)))
twisted.trial.unittest.FailTest: not equal:
a = ['/my/path/to/a/file/deep/in/the/woods/called/a file',
 '/my/path/to/anythingyouwant-to-defile']
b = ['/my/path/to/a/file/deep/in/the/woods/called/a file']

review: Needs Fixing
Revision history for this message
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_search.py, but you get the point…

Revision history for this message
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_by_pattern, the paths with spaces are sorted first anyway.

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.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches