Allow hiding a user from the frontpage task list.

This adds new query arguments to the taskList hub xmlrpc endpoint, and then
makes use of those arguments in koji-web.  A new optional configuration value
is added for koji-web: `HiddenUser`, which can be used to specify which user
account should be hidden.  This could be useful for deployments that have a
continuous-integration account, the spam from which makes the frontpage
difficult to read.

Unit test cases are also added for some functions of the hub taskList endpoint.

Signed-off-by: Ralph Bean <rbean@redhat.com>
This commit is contained in:
Ralph Bean 2016-05-13 21:06:56 -04:00 committed by Mike McLean
parent 1febe4f7fe
commit 708b6a411c
6 changed files with 99 additions and 4 deletions

View file

View file

@ -0,0 +1,60 @@
import unittest
import mock
import kojihub
class TestListing(unittest.TestCase):
def setUp(self):
self.hub = kojihub.RootExports()
self.standard_processor_kwargs = dict(
tables=mock.ANY,
columns=mock.ANY,
values=mock.ANY,
joins=mock.ANY,
clauses=mock.ANY,
opts=mock.ANY,
aliases=mock.ANY,
)
@mock.patch('kojihub.QueryProcessor')
def test_list_tasks_basic_invocation(self, processor):
generator = self.hub.listTasks()
results = list(generator) # Exhaust the generator
processor.assert_called_once_with(**self.standard_processor_kwargs)
@mock.patch('kojihub.QueryProcessor')
def test_list_tasks_by_owner(self, processor):
generator = self.hub.listTasks(opts={'owner': 1})
results = list(generator) # Exhaust the generator
arguments = self.standard_processor_kwargs.copy()
arguments['clauses'] = ['owner = %(owner)i']
processor.assert_called_once_with(**arguments)
self.assertEqual(results, [])
@mock.patch('kojihub.QueryProcessor')
def test_list_tasks_by_not_owner(self, processor):
generator = self.hub.listTasks(opts={'not_owner': 1})
results = list(generator) # Exhaust the generator
arguments = self.standard_processor_kwargs.copy()
arguments['clauses'] = ['owner != %(not_owner)i']
processor.assert_called_once_with(**arguments)
self.assertEqual(results, [])
@mock.patch('kojihub.QueryProcessor')
def test_list_tasks_by_arch(self, processor):
generator = self.hub.listTasks(opts={'arch': ['x86_64']})
results = list(generator) # Exhaust the generator
arguments = self.standard_processor_kwargs.copy()
arguments['clauses'] = ['arch IN %(arch)s']
processor.assert_called_once_with(**arguments)
self.assertEqual(results, [])
@mock.patch('kojihub.QueryProcessor')
def test_list_tasks_by_not_arch(self, processor):
generator = self.hub.listTasks(opts={'not_arch': ['x86_64']})
results = list(generator) # Exhaust the generator
arguments = self.standard_processor_kwargs.copy()
arguments['clauses'] = ['arch NOT IN %(not_arch)s']
processor.assert_called_once_with(**arguments)
self.assertEqual(results, [])