summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-12-13 18:46:19 +0000
committerGerrit Code Review <review@openstack.org>2018-12-13 18:46:19 +0000
commit6c00d7552bca6123fda7bfdd4d28ca7b3235faed (patch)
tree98190781c957960c6ccec2a1efafaa7a0f5f76f3
parentb93cf0d33d88c650978aec3c1be117b2007b8d65 (diff)
parentc5890ea0cc10dd6c2fa45ebc0ccdada63b2a4aa7 (diff)
Merge "Add playbook filtering by status"HEADmaster
-rw-r--r--ara/api/tests/tests_playbook.py7
-rw-r--r--ara/api/views.py2
2 files changed, 8 insertions, 1 deletions
diff --git a/ara/api/tests/tests_playbook.py b/ara/api/tests/tests_playbook.py
index e800398..d777fc3 100644
--- a/ara/api/tests/tests_playbook.py
+++ b/ara/api/tests/tests_playbook.py
@@ -121,6 +121,13 @@ class PlaybookTestCase(APITestCase):
121 self.assertEqual(1, len(request.data["results"])) 121 self.assertEqual(1, len(request.data["results"]))
122 self.assertEqual(playbook.name, request.data["results"][0]["name"]) 122 self.assertEqual(playbook.name, request.data["results"][0]["name"])
123 123
124 def test_get_playbook_by_status(self):
125 playbook = factories.PlaybookFactory(status="failed")
126 factories.PlaybookFactory(status="completed")
127 request = self.client.get("/api/v1/playbooks?status=failed")
128 self.assertEqual(1, len(request.data["results"]))
129 self.assertEqual(playbook.status, request.data["results"][0]["status"])
130
124 def test_get_playbook_duration(self): 131 def test_get_playbook_duration(self):
125 started = timezone.now() 132 started = timezone.now()
126 ended = started + datetime.timedelta(hours=1) 133 ended = started + datetime.timedelta(hours=1)
diff --git a/ara/api/views.py b/ara/api/views.py
index 40d9b0e..64156cc 100644
--- a/ara/api/views.py
+++ b/ara/api/views.py
@@ -29,7 +29,7 @@ class LabelViewSet(viewsets.ModelViewSet):
29class PlaybookViewSet(viewsets.ModelViewSet): 29class PlaybookViewSet(viewsets.ModelViewSet):
30 queryset = models.Playbook.objects.all() 30 queryset = models.Playbook.objects.all()
31 serializer_class = serializers.PlaybookSerializer 31 serializer_class = serializers.PlaybookSerializer
32 filter_fields = ("name",) 32 filter_fields = ("name", "status")
33 33
34 34
35class PlaybookFilesDetail(NestedViewSetMixin, viewsets.ModelViewSet): 35class PlaybookFilesDetail(NestedViewSetMixin, viewsets.ModelViewSet):