Skip to content

Commit

Permalink
Allow filtering on worker-pool title (exact filter).
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Jul 16, 2013
1 parent 709acf6 commit 8ebf1a3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion docs/apps/job_runner/rest.rst
Expand Up @@ -62,7 +62,12 @@ Worker-pools
~~~~~~~~~~~~

``GET /api/v1/worker_pool/``
Returns a list of available worker-pools.
Returns a list of available worker-pools. The following filters are
allowed:

title
The exact title of the worker-pool.


``GET /api/vi/worker-pools/{WORKER_POOL_ID}/``
Return the details of a specific worker-pool id.
Expand Down
3 changes: 3 additions & 0 deletions job_runner/apps/job_runner/api.py
Expand Up @@ -121,6 +121,9 @@ class Meta:
'description',
'enqueue_is_enabled',
]
filtering = {
'title': 'exact',
}

authentication = MultiAuthentication(
SessionAuthentication(), HmacAuthentication())
Expand Down
2 changes: 1 addition & 1 deletion job_runner/apps/job_runner/models.py
Expand Up @@ -171,7 +171,7 @@ class WorkerPool(models.Model):
"""
Worker-pool.
"""
title = models.CharField(max_length=255)
title = models.CharField(max_length=255, db_index=True)
description = models.TextField(blank=True)
notification_addresses = models.TextField(
help_text='Separate e-mail addresses by a newline',
Expand Down
11 changes: 11 additions & 0 deletions job_runner/apps/job_runner/tests/functional/test_api.py
Expand Up @@ -261,6 +261,17 @@ def test_user_authorization(self):
'/api/v1/worker_pool/2/', ACCEPT='application/json')
self.assertEqual(401, response.status_code)

def test_filter_on_title(self):
"""
Test filter on worker-pool title.
"""
response = self.get('/api/v1/worker_pool/?{0}'.format(
urllib.urlencode({'title': 'Pool 1'})))
self.assertEqual(200, response.status_code)

json_data = json.loads(response.content)
self.assertEqual(1, json_data['objects'][0]['id'])


class WorkerTestCase(ApiTestBase):
"""
Expand Down

0 comments on commit 8ebf1a3

Please sign in to comment.