Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akihikokuroda committed Jan 27, 2024
1 parent 0bd71c8 commit 85d0f26
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
6 changes: 4 additions & 2 deletions gateway/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ class RuntimeJobViewSet(views.RuntimeJobViewSet): # pylint: disable=too-many-an
RuntimeJob view set first version. Use RuntomeJobSerializer V1.
"""

queryset = RuntimeJob.objects.all()
serializer_class = v1_serializers.RuntimeJobSerializer
permission_classes = [permissions.IsAuthenticated]
permission_classes = [permissions.IsAuthenticated, IsOwner]

def get_serializer_class(self):
return v1_serializers.RuntimeJobSerializer

def get_queryset(self):
return RuntimeJob.objects.all().filter(job__author=self.request.user)
2 changes: 1 addition & 1 deletion gateway/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,4 @@ def get_serializer_class(self):
return self.serializer_class

def get_queryset(self):
return RuntimeJob.objects.all()
return RuntimeJob.objects.all().filter(job__author=self.request.user)
14 changes: 14 additions & 0 deletions gateway/tests/api/test_v1_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,17 @@ def test_runtime_job(self):
)
self.assertEqual(programs_response.status_code, status.HTTP_200_OK)
self.assertEqual(programs_response.json().get("count"), 2)

auth = reverse("rest_login")
response = self.client.post(
auth, {"username": "test_user_2", "password": "123"}, format="json"
)
token_2 = response.data.get("access")
self.client.credentials(HTTP_AUTHORIZATION="Bearer " + token_2)

programs_response = self.client.get(
"/api/v1/runtime_jobs/",
format="json",
)
self.assertEqual(programs_response.status_code, status.HTTP_200_OK)
self.assertEqual(programs_response.json().get("count"), 1)
2 changes: 1 addition & 1 deletion gateway/tests/api/test_v1_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ def test_create_job(self):
)

self.assertIsNotNone(job)
self.assertEqual(Job.objects.count(), 3)
self.assertEqual(Job.objects.count(), 4)
self.assertEqual(job.status, Job.QUEUED)
29 changes: 29 additions & 0 deletions gateway/tests/fixtures/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"is_active": true
}
},
{
"model": "auth.user",
"pk": 2,
"fields": {
"email": "[email protected]",
"username": "test_user_2",
"password": "pbkdf2_sha256$390000$kcex1rxhZg6VVJYkx71cBX$e4ns0xDykbO6Dz6j4nZ4uNusqkB9GVpojyegPv5/9KM=",
"is_active": true
}
},
{
"model": "api.program",
"pk": "1a7947f9-6ae8-4e3d-ac1e-e7d608deec82",
Expand Down Expand Up @@ -42,6 +52,17 @@
"author": 1
}
},
{
"model": "api.job",
"pk": "1a7947f9-6ae8-4e3d-ac1e-e7d608deec84",
"fields": {
"program": "1a7947f9-6ae8-4e3d-ac1e-e7d608deec82",
"created": "2023-02-01T15:30:43.281796Z",
"result": "{\"somekey\":1}",
"status": "QUEUED",
"author": 2
}
},
{
"model": "api.runtimejob",
"pk": "runtime_job_1",
Expand All @@ -65,5 +86,13 @@
"job": "1a7947f9-6ae8-4e3d-ac1e-e7d608deec82",
"runtime_job": "runtime_job_3"
}
},
{
"model": "api.runtimejob",
"pk": "runtime_job_4",
"fields": {
"job": "1a7947f9-6ae8-4e3d-ac1e-e7d608deec84",
"runtime_job": "runtime_job_5"
}
}
]

0 comments on commit 85d0f26

Please sign in to comment.