[Patchew-devel] [PATCH 2/3] add support for result PUT to mods/*
Shubham Jain
shubhamjain7495 at gmail.com
Wed Aug 8 12:07:10 UTC 2018
Please let me know if there is any corner case I'm missing or add general
tests.
On Wed, Aug 8, 2018 at 4:42 PM Shubham Jain <shubhamjain7495 at gmail.com>
wrote:
> Added serializer to validate data field in the PUT of the result
> ---
> mods/git.py | 11 ++++++++++-
> mods/testing.py | 10 ++++++++--
> 2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/mods/git.py b/mods/git.py
> index 924547a..0e1de86 100644
> --- a/mods/git.py
> +++ b/mods/git.py
> @@ -23,6 +23,9 @@ from api.rest import PluginMethodField
> from api.views import APILoginRequiredView, prepare_series
> from patchew.logviewer import LogView
> from schema import *
> +from rest_framework import serializers
> +from rest_framework import serializers
> +from rest_framework.fields import CharField
>
> _instance = None
>
> @@ -42,11 +45,17 @@ class GitLogViewer(LogView):
> raise Http404("Object not found: " + series)
> return obj.git_result
>
> +class DataSerializer(serializers.Serializer):
> + repo = CharField()
> + url = CharField()
> + base = CharField()
> + tag = CharField()
>
> class GitModule(PatchewModule):
> """Git module"""
> name = "git"
> -
> + allowed_groups = ('importers', )
> + result_data_serializer_class = DataSerializer
> project_property_schema = \
> ArraySchema("git", desc="Configuration for git module",
> members=[
> diff --git a/mods/testing.py b/mods/testing.py
> index 0a80b3d..37831b7 100644
> --- a/mods/testing.py
> +++ b/mods/testing.py
> @@ -24,7 +24,8 @@ from api.search import SearchEngine
> from event import emit_event, declare_event, register_handler
> from patchew.logviewer import LogView
> from schema import *
> -
> +from rest_framework import serializers
> +from rest_framework.fields import CharField, BooleanField
> _instance = None
>
> TESTING_SCRIPT_DEFAULT = """#!/bin/bash
> @@ -46,12 +47,17 @@ class TestingLogViewer(LogView):
> raise Http404("Object not found: " + project_or_series)
> return _instance.get_testing_result(obj, testing_name)
>
> +class DataSerializer(serializers.Serializer):
> + is_timeout = BooleanField()
> + head = CharField()
> + tester = CharField()
>
> class TestingModule(PatchewModule):
> """Testing module"""
>
> name = "testing"
> -
> + allowed_groups = ('testers', )
> + result_data_serializer_class = DataSerializer
> test_schema = \
> ArraySchema("{name}", "Test", desc="Test spec",
> members=[
> --
> 2.15.1 (Apple Git-101)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/patchew-devel/attachments/20180808/fc6ef32f/attachment.htm>
More information about the Patchew-devel
mailing list