##// END OF EJS Templates
changed the tests for search....
marcink -
r2740:8ee8f4dc beta
parent child Browse files
Show More
@@ -1,99 +1,114
1 import os
1 import os
2 from rhodecode.tests import *
2 from rhodecode.tests import *
3 from nose.plugins.skip import SkipTest
3 from nose.plugins.skip import SkipTest
4
4
5
5
6 class TestSearchController(TestController):
6 class TestSearchController(TestController):
7
7
8 def test_index(self):
8 def test_index(self):
9 self.log_user()
9 self.log_user()
10 response = self.app.get(url(controller='search', action='index'))
10 response = self.app.get(url(controller='search', action='index'))
11
11
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
12 self.assertTrue('class="small" id="q" name="q" type="text"' in
13 response.body)
13 response.body)
14 # Test response...
14 # Test response...
15
15
16 def test_empty_search(self):
16 def test_empty_search(self):
17 if os.path.isdir(self.index_location):
17 if os.path.isdir(self.index_location):
18 raise SkipTest('skipped due to existing index')
18 raise SkipTest('skipped due to existing index')
19 else:
19 else:
20 self.log_user()
20 self.log_user()
21 response = self.app.get(url(controller='search', action='index'),
21 response = self.app.get(url(controller='search', action='index'),
22 {'q': HG_REPO})
22 {'q': HG_REPO})
23 self.assertTrue('There is no index to search in. '
23 self.assertTrue('There is no index to search in. '
24 'Please run whoosh indexer' in response.body)
24 'Please run whoosh indexer' in response.body)
25
25
26 def test_normal_search(self):
26 def test_normal_search(self):
27 self.log_user()
27 self.log_user()
28 response = self.app.get(url(controller='search', action='index'),
28 response = self.app.get(url(controller='search', action='index'),
29 {'q': 'def repo'})
29 {'q': 'def repo'})
30 response.mustcontain('39 results')
30 response.mustcontain('39 results')
31
31
32 def test_repo_search(self):
32 def test_repo_search(self):
33 self.log_user()
33 self.log_user()
34 response = self.app.get(url(controller='search', action='index'),
34 response = self.app.get(url(controller='search', action='index'),
35 {'q': 'repository:%s def test' % HG_REPO})
35 {'q': 'repository:%s def test' % HG_REPO})
36
36
37 response.mustcontain('4 results')
37 response.mustcontain('4 results')
38
38
39 def test_search_last(self):
39 def test_search_last(self):
40 self.log_user()
40 self.log_user()
41 response = self.app.get(url(controller='search', action='index'),
41 response = self.app.get(url(controller='search', action='index'),
42 {'q': 'last:t', 'type': 'commit'})
42 {'q': 'last:t', 'type': 'commit'})
43
43
44 response.mustcontain('2 results')
44 response.mustcontain('2 results')
45
45
46 def test_search_commit_message(self):
46 def test_search_commit_message(self):
47 self.log_user()
47 self.log_user()
48 response = self.app.get(url(controller='search', action='index'),
48 response = self.app.get(url(controller='search', action='index'),
49 {'q': 'bother to ask where to fetch repo during tests',
49 {'q': 'bother to ask where to fetch repo during tests',
50 'type': 'commit'})
50 'type': 'commit'})
51
51
52 response.mustcontain('2 results')
52 response.mustcontain('2 results')
53 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
53 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
54 response.mustcontain('c6eb379775c578a95dad8ddab53f963b80894850')
54 response.mustcontain('c6eb379775c578a95dad8ddab53f963b80894850')
55
55
56 def test_search_commit_message_hg_repo(self):
56 def test_search_commit_message_hg_repo(self):
57 self.log_user()
57 self.log_user()
58 response = self.app.get(url(controller='search', action='index',
58 response = self.app.get(url(controller='search', action='index',
59 search_repo=HG_REPO),
59 search_repo=HG_REPO),
60 {'q': 'bother to ask where to fetch repo during tests',
60 {'q': 'bother to ask where to fetch repo during tests',
61 'type': 'commit'})
61 'type': 'commit'})
62
62
63 response.mustcontain('1 results')
63 response.mustcontain('1 results')
64 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
64 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
65
65
66 def test_search_commit_changed_file(self):
66 def test_search_commit_changed_file(self):
67 self.log_user()
67 self.log_user()
68 response = self.app.get(url(controller='search', action='index'),
68 response = self.app.get(url(controller='search', action='index'),
69 {'q': 'changed:tests/utils.py',
69 {'q': 'changed:tests/utils.py',
70 'type': 'commit'})
70 'type': 'commit'})
71
71
72 response.mustcontain('a00c1b6f5d7a6ae678fd553a8b81d92367f7ecf1')
72 response.mustcontain('20 results')
73
74 def test_search_commit_changed_files_get_commit(self):
75 self.log_user()
76 response = self.app.get(url(controller='search', action='index'),
77 {'q': 'changed:vcs/utils/lazy.py',
78 'type': 'commit'})
79
80 response.mustcontain('7 results')
81 response.mustcontain('36e0fc9d2808c5022a24f49d6658330383ed8666')
82 response.mustcontain('af182745859d779f17336241a0815d15166ae1ee')
83 response.mustcontain('17438a11f72b93f56d0e08e7d1fa79a378578a82')
84 response.mustcontain('33fa3223355104431402a888fa77a4e9956feb3e')
85 response.mustcontain('d1f898326327e20524fe22417c22d71064fe54a1')
86 response.mustcontain('fe568b4081755c12abf6ba673ba777fc02a415f3')
87 response.mustcontain('bafe786f0d8c2ff7da5c1dcfcfa577de0b5e92f1')
73
88
74 def test_search_commit_added_file(self):
89 def test_search_commit_added_file(self):
75 self.log_user()
90 self.log_user()
76 response = self.app.get(url(controller='search', action='index'),
91 response = self.app.get(url(controller='search', action='index'),
77 {'q': 'added:README.rst',
92 {'q': 'added:README.rst',
78 'type': 'commit'})
93 'type': 'commit'})
79
94
80 response.mustcontain('2 results')
95 response.mustcontain('2 results')
81 #HG
96 #HG
82 response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
97 response.mustcontain('3803844fdbd3b711175fc3da9bdacfcd6d29a6fb')
83 #GIT
98 #GIT
84 response.mustcontain('ff7ca51e58c505fec0dd2491de52c622bb7a806b')
99 response.mustcontain('ff7ca51e58c505fec0dd2491de52c622bb7a806b')
85
100
86 def test_search_author(self):
101 def test_search_author(self):
87 self.log_user()
102 self.log_user()
88 response = self.app.get(url(controller='search', action='index'),
103 response = self.app.get(url(controller='search', action='index'),
89 {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545',
104 {'q': 'author:marcin@python-blog.com raw_id:b986218ba1c9b0d6a259fac9b050b1724ed8e545',
90 'type': 'commit'})
105 'type': 'commit'})
91
106
92 response.mustcontain('1 results')
107 response.mustcontain('1 results')
93
108
94 def test_search_file_name(self):
109 def test_search_file_name(self):
95 self.log_user()
110 self.log_user()
96 response = self.app.get(url(controller='search', action='index'),
111 response = self.app.get(url(controller='search', action='index'),
97 {'q': 'README.rst', 'type': 'path'})
112 {'q': 'README.rst', 'type': 'path'})
98
113
99 response.mustcontain('2 results') No newline at end of file
114 response.mustcontain('2 results')
General Comments 0
You need to be logged in to leave comments. Login now