From 864e0b481bb1eea9347cdb2bf6812dda4935d6c4 Mon Sep 17 00:00:00 2001 From: David Moreau Simard Date: Tue, 16 Oct 2018 10:19:16 -0400 Subject: [PATCH] Add play filtering by uuid Change-Id: I8ec1fdd6d79838dc64e519e0c8ae9b5c5fb22524 --- ara/api/tests/tests_play.py | 7 +++++++ ara/api/views.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ara/api/tests/tests_play.py b/ara/api/tests/tests_play.py index e7833f2..1c4a695 100644 --- a/ara/api/tests/tests_play.py +++ b/ara/api/tests/tests_play.py @@ -96,6 +96,13 @@ class PlayTestCase(APITestCase): self.assertEqual(1, len(request.data["results"])) self.assertEqual(play.name, request.data["results"][0]["name"]) + def test_get_play_by_uuid(self): + play = factories.PlayFactory(name="play1", uuid="6b838b6f-cfc7-4e11-a264-73df8683ee0e") + factories.PlayFactory(name="play2") + request = self.client.get("/api/v1/plays?uuid=6b838b6f-cfc7-4e11-a264-73df8683ee0e") + self.assertEqual(1, len(request.data["results"])) + self.assertEqual(play.name, request.data["results"][0]["name"]) + def test_get_play_duration(self): started = timezone.now() ended = started + datetime.timedelta(hours=1) diff --git a/ara/api/views.py b/ara/api/views.py index 0ea0fff..81d7af2 100644 --- a/ara/api/views.py +++ b/ara/api/views.py @@ -49,7 +49,7 @@ class PlayViewSet(viewsets.ModelViewSet): queryset = models.Play.objects.all() serializer_class = serializers.PlaySerializer filter_backends = (DjangoFilterBackend,) - filter_fields = ("playbook",) + filter_fields = ("playbook", "uuid") class TaskViewSet(viewsets.ModelViewSet):