Skip to content

Commit

Permalink
Add filter dist_git_branch for release component
Browse files Browse the repository at this point in the history
JIRA: PDC-1038
  • Loading branch information
erichuanggit committed Oct 13, 2015
1 parent 27f89b9 commit c88711b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pdc/apps/component/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class ReleaseComponentFilter(ComposeFilterSet):
brew_package = MultiValueFilter()
active = CaseInsensitiveBooleanFilter()
type = CharFilter(name='type__name')
dist_git_branch = MultiValueFilter()

@value_is_not_empty
def filter_together(self, qs, value):
Expand Down Expand Up @@ -259,7 +260,7 @@ def filter_together(self, qs, value):
class Meta:
model = ReleaseComponent
fields = ('name', 'release', 'email', 'contact_role', 'global_component', 'active',
'bugzilla_component', 'type')
'bugzilla_component', 'type', 'dist_git_branch')


class BugzillaComponentFilter(ComposeFilterSet):
Expand Down
11 changes: 11 additions & 0 deletions pdc/apps/component/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,17 @@ def test_filter_release_component_by_wrong_active(self):
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 0)

def test_filter_release_component_by_dist_git_branch(self):
url = reverse('releasecomponent-detail', kwargs={'pk': 1})
data = {'dist_git_branch': 'python3.0'}
response = self.client.patch(url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)

url = reverse('releasecomponent-list')
response = self.client.get(url + '?dist_git_branch=python3.0', format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 1)

def test_detail_release_component(self):
url = reverse('releasecomponent-detail', kwargs={'pk': 1})
response = self.client.get(url, format='json')
Expand Down

0 comments on commit c88711b

Please sign in to comment.