示例#1
0
 def get(self, request, *args, **kwargs):
     option_name = self.kwargs['option_name']
     option = Options.find(option_name=option_name)
     return Response(option.to_dict(), status=status.HTTP_200_OK)
示例#2
0
 def get(self, request, *args, **kwargs):
     project = get_object_or_404(Project, pk=self.kwargs['project_id'])
     options = Options.filter_by_task(task_name=project.project_type)
     option_names = [o.name for o in options]
     return Response(option_names, status=status.HTTP_200_OK)
def test_find_invalid_option():
    with pytest.raises(ValueError):
        Options.find('XXX')
def test_find_option(option_name):
    option = Options.find(option_name)
    assert option.name == option_name
def test_filter_task(task, expected):
    options = Options.filter_by_task(task_name=task)
    tasks = {o.task for o in options}
    assert tasks == expected
示例#6
0
 def get(self, request: Request, *args, **kwargs):
     task_name = request.query_params.get("task_name")
     options = Options.filter_by_task(task_name=task_name)
     option_names = [o.name for o in options]
     return Response(option_names, status=status.HTTP_200_OK)