annotate rhodecode/tests/functional/test_search.py @ 2640:5f21a9dcb09d beta

create an index for commit messages and the ability to search them and see results
author Indra Talip <indra.talip@gmail.com>
date Fri, 20 Jul 2012 12:50:56 +0200
parents 9492ab68331f
children 2ad50c44b025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2459
9492ab68331f Initial version of landing revisions ref #483
Marcin Kuzminski <marcin@python-works.com>
parents: 2451
diff changeset
1 import os
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 483
diff changeset
2 from rhodecode.tests import *
469
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 464
diff changeset
3 from nose.plugins.skip import SkipTest
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
5
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 class TestSearchController(TestController):
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 def test_index(self):
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 406
diff changeset
9 self.log_user()
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 response = self.app.get(url(controller='search', action='index'))
1401
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
11
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
13 response.body)
406
b153a51b1d3b Implemented search using whoosh. Still as experimental option.
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # Test response...
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 406
diff changeset
15
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 406
diff changeset
16 def test_empty_search(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
17 if os.path.isdir(self.index_location):
469
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 464
diff changeset
18 raise SkipTest('skipped due to existing index')
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 464
diff changeset
19 else:
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 464
diff changeset
20 self.log_user()
1401
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
21 response = self.app.get(url(controller='search', action='index'),
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
22 {'q': HG_REPO})
1401
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
23 self.assertTrue('There is no index to search in. '
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
24 'Please run whoosh indexer' in response.body)
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
25
469
e94f4e54dc03 tests fix, put vcs testing tarball
Marcin Kuzminski <marcin@python-works.com>
parents: 464
diff changeset
26 def test_normal_search(self):
464
cbe777be5b8c some more basic tests
Marcin Kuzminski <marcin@python-works.com>
parents: 406
diff changeset
27 self.log_user()
1401
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
28 response = self.app.get(url(controller='search', action='index'),
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
29 {'q': 'def repo'})
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
30 response.mustcontain('10 results')
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
31
483
a9e50dce3081 Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
32 def test_repo_search(self):
a9e50dce3081 Removed config names from whoosh and celery,
Marcin Kuzminski <marcin@python-works.com>
parents: 469
diff changeset
33 self.log_user()
1401
b7563ad4e7ee Unicode fixes, added safe_str method for global str() operations +better test sandboxing
Marcin Kuzminski <marcin@python-works.com>
parents: 1203
diff changeset
34 response = self.app.get(url(controller='search', action='index'),
2451
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
35 {'q': 'repository:%s def test' % HG_REPO})
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
36
402a96fcfa22 Added vcs testsuite for better integration tests + added fetching
Marcin Kuzminski <marcin@python-works.com>
parents: 1401
diff changeset
37 response.mustcontain('4 results')
2640
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
38
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
39 def test_search_last(self):
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
40 self.log_user()
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
41 response = self.app.get(url(controller='search', action='index'),
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
42 {'q': 'last:t', 'type': 'commit'})
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
43
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
44 response.mustcontain('1 results')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
45
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
46 def test_search_commit_message(self):
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
47 self.log_user()
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
48 response = self.app.get(url(controller='search', action='index'),
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
49 {'q': 'bother to ask where to fetch repo during tests',
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
50 'type': 'commit'})
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
51
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
52 response.mustcontain('1 results')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
53 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
54
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
55 def test_search_commit_changed_file(self):
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
56 self.log_user()
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
57 response = self.app.get(url(controller='search', action='index'),
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
58 {'q': 'changed:tests/utils.py',
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
59 'type': 'commit'})
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
60
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
61 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
62
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
63 def test_search_commit_added_file(self):
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
64 self.log_user()
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
65 response = self.app.get(url(controller='search', action='index'),
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
66 {'q': 'added:README.rst',
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
67 'type': 'commit'})
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
68
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
69 response.mustcontain('1 results')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
70 response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
71
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
72 def test_search_author(self):
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
73 self.log_user()
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
74 response = self.app.get(url(controller='search', action='index'),
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
75 {'q': 'author:marcin@python-blog.com revision:0',
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
76 'type': 'commit'})
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
77
5f21a9dcb09d create an index for commit messages and the ability to search them and see results
Indra Talip <indra.talip@gmail.com>
parents: 2459
diff changeset
78 response.mustcontain('1 results')