Mercurial > kallithea
diff kallithea/tests/functional/test_admin.py @ 6472:e6224a7c3d4e
tests: introduce more test coverage of whoosh filtering
This has been extracted from other changesets by Mads Kiilerich to establish a
test baseline so we clearly can see what the following fixes are fixing.
Some of these tests will thus demonstrate bad behaviour - that will be fixed
later.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 23 Jan 2017 02:17:38 +0900 |
parents | 8d98924c58b1 |
children | 73e3599971da |
line wrap: on
line diff
--- a/kallithea/tests/functional/test_admin.py Mon Jan 23 02:17:38 2017 +0900 +++ b/kallithea/tests/functional/test_admin.py Mon Jan 23 02:17:38 2017 +0900 @@ -56,94 +56,140 @@ def test_filter_all_entries(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index',)) - response.mustcontain('2034 Entries') + response.mustcontain(' 2036 Entries') def test_filter_journal_filter_exact_match_on_repository(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:xxx')) - response.mustcontain('3 Entries') + response.mustcontain(' 3 Entries') def test_filter_journal_filter_exact_match_on_repository_CamelCase(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:XxX')) - response.mustcontain('3 Entries') + response.mustcontain(' 3 Entries') def test_filter_journal_filter_wildcard_on_repository(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:*test*')) - response.mustcontain('862 Entries') + response.mustcontain(' 862 Entries') def test_filter_journal_filter_prefix_on_repository(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:test*')) - response.mustcontain('257 Entries') + response.mustcontain(' 257 Entries') def test_filter_journal_filter_prefix_on_repository_CamelCase(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:Test*')) - response.mustcontain('257 Entries') + response.mustcontain(' 257 Entries') def test_filter_journal_filter_prefix_on_repository_and_user(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:test* AND username:demo')) - response.mustcontain('130 Entries') + response.mustcontain(' 130 Entries') def test_filter_journal_filter_prefix_on_repository_or_other_repo(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='repository:test* OR repository:xxx')) - response.mustcontain('260 Entries') # 257 + 3 + response.mustcontain(' 260 Entries') # 257 + 3 def test_filter_journal_filter_exact_match_on_username(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='username:demo')) - response.mustcontain('1087 Entries') + response.mustcontain(' 1087 Entries') def test_filter_journal_filter_exact_match_on_username_camelCase(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='username:DemO')) - response.mustcontain('1087 Entries') + response.mustcontain(' 1087 Entries') def test_filter_journal_filter_wildcard_on_username(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='username:*test*')) - response.mustcontain('100 Entries') + response.mustcontain(' 100 Entries') def test_filter_journal_filter_prefix_on_username(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='username:demo*')) - response.mustcontain('1101 Entries') + response.mustcontain(' 1101 Entries') def test_filter_journal_filter_prefix_on_user_or_other_user(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='username:demo OR username:volcan')) - response.mustcontain('1095 Entries') # 1087 + 8 + response.mustcontain(' 1095 Entries') # 1087 + 8 def test_filter_journal_filter_wildcard_on_action(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='action:*pull_request*')) - response.mustcontain('187 Entries') + response.mustcontain(' 187 Entries') def test_filter_journal_filter_on_date(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='date:20121010')) - response.mustcontain('47 Entries') + response.mustcontain(' 47 Entries') def test_filter_journal_filter_on_date_2(self): self.log_user() response = self.app.get(url(controller='admin/admin', action='index', filter='date:20121020')) - response.mustcontain('17 Entries') + response.mustcontain(' 17 Entries') + + @parametrize('filter,hit', [ + #### "repository:" filtering + # "/" is used for grouping + ('repository:group/test', 0), + # "-" is often used for "-fork" + ('repository:fork-test1', 0), + # using "stop words" + ('repository:this', 2036), + ('repository:this/is-it', 2036), + + ## additional tests to quickly find out regression in the future + ## (and check case-insensitive search, too) + # non-ascii character "." and "-" + ('repository:TESTIES1.2.3', 4), + ('repository:test_git_repo', 2), + # combination with wildcard "*" + ('repository:GROUP/*', 182), + ('repository:*/test', 7), + ('repository:fork-*', 273), + ('repository:*-Test1', 5), + + #### "username:" filtering + # "-" is valid character + ('username:peso-xxx', 0), + # using "stop words" + ('username:this-is-it', 2036), + + ## additional tests to quickly find out regression in the future + ## (and check case-insensitive search, too) + # non-ascii character "." and "-" + ('username:ADMIN_xanroot', 6), + ('username:robert.Zaremba', 3), + # combination with wildcard "*" + ('username:THIS-*', 2), + ('username:*-IT', 2), + ]) + def test_filter_journal_filter_tokenization(self, filter, hit): + self.log_user() + + response = self.app.get(url(controller='admin/admin', action='index', + filter=filter)) + if hit != 1: + response.mustcontain(' %s Entries' % hit) + else: + response.mustcontain(' 1 Entry')