Mercurial > kallithea
annotate kallithea/tests/functional/test_admin.py @ 7811:0a277465fddf
scripts: initial run of import cleanup using isort
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 07 Aug 2019 00:25:02 +0200 |
parents | 2ff913970025 |
children | e527cc2ce8dc |
rev | line source |
---|---|
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
1 import csv |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
2 import datetime |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
3 import os |
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
4 from os.path import dirname |
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
5 |
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
6 from kallithea.lib.utils2 import safe_unicode |
4186
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3074
diff
changeset
|
7 from kallithea.model.db import UserLog |
7e5f8c12a3fc
First step in two-part process to rename directories to kallithea.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3074
diff
changeset
|
8 from kallithea.model.meta import Session |
7811
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
9 from kallithea.tests.base import * |
0a277465fddf
scripts: initial run of import cleanup using isort
Mads Kiilerich <mads@kiilerich.com>
parents:
6474
diff
changeset
|
10 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
11 |
5998
037efd94e955
cleanup: get rid of dn as shortcut for os.path.dirname
domruf <dominikruf@gmail.com>
parents:
5922
diff
changeset
|
12 FIXTURES = os.path.join(dirname(dirname(os.path.abspath(__file__))), 'fixtures') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
13 |
43 | 14 |
5922
7f2aa3ec2931
pytest migration: rename TestControllerPytest back to TestController
Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
parents:
5801
diff
changeset
|
15 class TestAdminController(TestController): |
43 | 16 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
17 @classmethod |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
18 def setup_class(cls): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
19 UserLog.query().delete() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
20 Session().commit() |
3074
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
21 |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
22 def strptime(val): |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
23 fmt = '%Y-%m-%d %H:%M:%S' |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
24 if '.' not in val: |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
25 return datetime.datetime.strptime(val, fmt) |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
26 |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
27 nofrag, frag = val.split(".") |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
28 date = datetime.datetime.strptime(nofrag, fmt) |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
29 |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
30 frag = frag[:6] # truncate to microseconds |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
31 frag += (6 - len(frag)) * '0' # add 0s |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
32 return date.replace(microsecond=int(frag)) |
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
33 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
34 with open(os.path.join(FIXTURES, 'journal_dump.csv')) as f: |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
35 for row in csv.DictReader(f): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
36 ul = UserLog() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
37 for k, v in row.iteritems(): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
38 v = safe_unicode(v) |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
39 if k == 'action_date': |
3074
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
40 v = strptime(v) |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
41 if k in ['user_id', 'repository_id']: |
3074
09cef303962b
python2.5 safe parsing of datetime string with microseconds
Marcin Kuzminski <marcin@python-works.com>
parents:
3072
diff
changeset
|
42 # nullable due to FK problems |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
43 v = None |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
44 setattr(ul, k, v) |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
45 Session().add(ul) |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
46 Session().commit() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
47 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
48 @classmethod |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
49 def teardown_class(cls): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
50 UserLog.query().delete() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
51 Session().commit() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
52 |
43 | 53 def test_index(self): |
473
6b934c9607e7
Improved testing scenarios. Made test env creator
Marcin Kuzminski <marcin@python-works.com>
parents:
459
diff
changeset
|
54 self.log_user() |
459
7c978511c951
implemented basic (startup) nose test suite.
Marcin Kuzminski <marcin@python-works.com>
parents:
43
diff
changeset
|
55 response = self.app.get(url(controller='admin/admin', action='index')) |
4527
dacdea9fda2a
Correct capitalization and improved English text in the UI
Na'Tosha Bard <natosha@unity3d.com>
parents:
4206
diff
changeset
|
56 response.mustcontain('Admin Journal') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
57 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
58 def test_filter_all_entries(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
59 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
60 response = self.app.get(url(controller='admin/admin', action='index',)) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
61 response.mustcontain(' 2036 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
62 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
63 def test_filter_journal_filter_exact_match_on_repository(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
64 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
65 response = self.app.get(url(controller='admin/admin', action='index', |
4206
703d3208424c
Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
66 filter='repository:xxx')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
67 response.mustcontain(' 3 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
68 |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
69 def test_filter_journal_filter_exact_match_on_repository_CamelCase(self): |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
70 self.log_user() |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
71 response = self.app.get(url(controller='admin/admin', action='index', |
4206
703d3208424c
Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
72 filter='repository:XxX')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
73 response.mustcontain(' 3 Entries') |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
74 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
75 def test_filter_journal_filter_wildcard_on_repository(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
76 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
77 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
78 filter='repository:*test*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
79 response.mustcontain(' 862 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
80 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
81 def test_filter_journal_filter_prefix_on_repository(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
82 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
83 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
84 filter='repository:test*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
85 response.mustcontain(' 257 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
86 |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
87 def test_filter_journal_filter_prefix_on_repository_CamelCase(self): |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
88 self.log_user() |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
89 response = self.app.get(url(controller='admin/admin', action='index', |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
90 filter='repository:Test*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
91 response.mustcontain(' 257 Entries') |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
92 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
93 def test_filter_journal_filter_prefix_on_repository_and_user(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
94 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
95 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
96 filter='repository:test* AND username:demo')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
97 response.mustcontain(' 130 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
98 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
99 def test_filter_journal_filter_prefix_on_repository_or_other_repo(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
100 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
101 response = self.app.get(url(controller='admin/admin', action='index', |
4206
703d3208424c
Rename various strings for tests
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
4187
diff
changeset
|
102 filter='repository:test* OR repository:xxx')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
103 response.mustcontain(' 260 Entries') # 257 + 3 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
104 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
105 def test_filter_journal_filter_exact_match_on_username(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
106 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
107 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
108 filter='username:demo')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
109 response.mustcontain(' 1087 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
110 |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
111 def test_filter_journal_filter_exact_match_on_username_camelCase(self): |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
112 self.log_user() |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
113 response = self.app.get(url(controller='admin/admin', action='index', |
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
114 filter='username:DemO')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
115 response.mustcontain(' 1087 Entries') |
3072
86e087bd75ce
fixed tests, made the journal filter consistent accross different databases
Marcin Kuzminski <marcin@python-works.com>
parents:
3071
diff
changeset
|
116 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
117 def test_filter_journal_filter_wildcard_on_username(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
118 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
119 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
120 filter='username:*test*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
121 response.mustcontain(' 100 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
122 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
123 def test_filter_journal_filter_prefix_on_username(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
124 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
125 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
126 filter='username:demo*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
127 response.mustcontain(' 1101 Entries') |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
128 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
129 def test_filter_journal_filter_prefix_on_user_or_other_user(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
130 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
131 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
132 filter='username:demo OR username:volcan')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
133 response.mustcontain(' 1095 Entries') # 1087 + 8 |
3063
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
134 |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
135 def test_filter_journal_filter_wildcard_on_action(self): |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
136 self.log_user() |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
137 response = self.app.get(url(controller='admin/admin', action='index', |
ca2b21819dfd
Implemented better support for Wildcard queries
Marcin Kuzminski <marcin@python-works.com>
parents:
628
diff
changeset
|
138 filter='action:*pull_request*')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
139 response.mustcontain(' 187 Entries') |
3070
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
140 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
141 def test_filter_journal_filter_on_date(self): |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
142 self.log_user() |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
143 response = self.app.get(url(controller='admin/admin', action='index', |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
144 filter='date:20121010')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
145 response.mustcontain(' 47 Entries') |
3070
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
146 |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
147 def test_filter_journal_filter_on_date_2(self): |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
148 self.log_user() |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
149 response = self.app.get(url(controller='admin/admin', action='index', |
cc7eedb5323c
final implementation of #210 journal filtering.
Marcin Kuzminski <marcin@python-works.com>
parents:
3063
diff
changeset
|
150 filter='date:20121020')) |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
151 response.mustcontain(' 17 Entries') |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
152 |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
153 @parametrize('filter,hit', [ |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
154 #### "repository:" filtering |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
155 # "/" is used for grouping |
6473
73e3599971da
journal: make "repository:" filtering condition work as expected (Issue #261)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6472
diff
changeset
|
156 ('repository:group/test', 4), |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
157 # "-" is often used for "-fork" |
6473
73e3599971da
journal: make "repository:" filtering condition work as expected (Issue #261)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6472
diff
changeset
|
158 ('repository:fork-test1', 5), |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
159 # using "stop words" |
6473
73e3599971da
journal: make "repository:" filtering condition work as expected (Issue #261)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6472
diff
changeset
|
160 ('repository:this', 1), |
73e3599971da
journal: make "repository:" filtering condition work as expected (Issue #261)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6472
diff
changeset
|
161 ('repository:this/is-it', 1), |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
162 |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
163 ## additional tests to quickly find out regression in the future |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
164 ## (and check case-insensitive search, too) |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
165 # non-ascii character "." and "-" |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
166 ('repository:TESTIES1.2.3', 4), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
167 ('repository:test_git_repo', 2), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
168 # combination with wildcard "*" |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
169 ('repository:GROUP/*', 182), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
170 ('repository:*/test', 7), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
171 ('repository:fork-*', 273), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
172 ('repository:*-Test1', 5), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
173 |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
174 #### "username:" filtering |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
175 # "-" is valid character |
6474
2ff913970025
journal: make "username:" filtering condition work as expected
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6473
diff
changeset
|
176 ('username:peso-xxx', 4), |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
177 # using "stop words" |
6474
2ff913970025
journal: make "username:" filtering condition work as expected
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6473
diff
changeset
|
178 ('username:this-is-it', 2), |
6472
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
179 |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
180 ## additional tests to quickly find out regression in the future |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
181 ## (and check case-insensitive search, too) |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
182 # non-ascii character "." and "-" |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
183 ('username:ADMIN_xanroot', 6), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
184 ('username:robert.Zaremba', 3), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
185 # combination with wildcard "*" |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
186 ('username:THIS-*', 2), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
187 ('username:*-IT', 2), |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
188 ]) |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
189 def test_filter_journal_filter_tokenization(self, filter, hit): |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
190 self.log_user() |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
191 |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
192 response = self.app.get(url(controller='admin/admin', action='index', |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
193 filter=filter)) |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
194 if hit != 1: |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
195 response.mustcontain(' %s Entries' % hit) |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
196 else: |
e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
6217
diff
changeset
|
197 response.mustcontain(' 1 Entry') |