Skip to content

Commit

Permalink
Add search by service uid to baseobject API (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
szok committed Oct 18, 2016
1 parent 73e79b0 commit c57ef70
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ralph/assets/api/views.py
Expand Up @@ -139,6 +139,7 @@ class BaseObjectViewSet(PolymorphicViewSetMixin, RalphAPIViewSet):
'barcode': ['asset__barcode'],
'price': ['asset__price'],
'ip': ['ethernet_set__ipaddress__address'],
'uid': ['service_env__service__uid'],
'service': ['service_env__service__uid', 'service_env__service__name'],
'env': ['service_env__environment__name'],
}
Expand Down
9 changes: 9 additions & 0 deletions src/ralph/assets/tests/test_api.py
Expand Up @@ -658,6 +658,15 @@ def test_filter_by_service_uid(self):
response = self.client.get(url, format='json')
self.assertEqual(len(response.data['results']), 1)

def test_filter_by_uid(self):
url = '{}?{}'.format(
reverse('baseobject-list'), urlencode(
{'uid': self.dc_asset.service_env.service.uid}
)
)
response = self.client.get(url, format='json')
self.assertEqual(len(response.data['results']), 1)

def test_filter_by_service_name(self):
url = '{}?{}'.format(
reverse('baseobject-list'), urlencode(
Expand Down

0 comments on commit c57ef70

Please sign in to comment.