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