Add play filtering by uuid

Change-Id: I8ec1fdd6d79838dc64e519e0c8ae9b5c5fb22524
This commit is contained in:
David Moreau Simard 2018-10-16 10:19:16 -04:00
parent 70f248c24f
commit 864e0b481b
No known key found for this signature in database
GPG Key ID: CBEB466764A9E621
2 changed files with 8 additions and 1 deletions

View File

@ -96,6 +96,13 @@ class PlayTestCase(APITestCase):
self.assertEqual(1, len(request.data["results"])) self.assertEqual(1, len(request.data["results"]))
self.assertEqual(play.name, request.data["results"][0]["name"]) 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): def test_get_play_duration(self):
started = timezone.now() started = timezone.now()
ended = started + datetime.timedelta(hours=1) ended = started + datetime.timedelta(hours=1)

View File

@ -49,7 +49,7 @@ class PlayViewSet(viewsets.ModelViewSet):
queryset = models.Play.objects.all() queryset = models.Play.objects.all()
serializer_class = serializers.PlaySerializer serializer_class = serializers.PlaySerializer
filter_backends = (DjangoFilterBackend,) filter_backends = (DjangoFilterBackend,)
filter_fields = ("playbook",) filter_fields = ("playbook", "uuid")
class TaskViewSet(viewsets.ModelViewSet): class TaskViewSet(viewsets.ModelViewSet):