Ejemplo n.º 1
0
    def test_generate_xml_from_scheme_with_arg_title(self):
        """Checks that the XML generated by a Scheme object with all its fields set and
        some arguments added matches what we expect. Also sets the title on an argument."""

        scheme = Scheme("abcd")
        scheme.description = u"쎼 and 쎶 and <&> für"
        scheme.streaming_mode = Scheme.streaming_mode_simple
        scheme.use_external_validation = "false"
        scheme.use_single_instance = "true"

        arg1 = Argument(name="arg1")
        scheme.add_argument(arg1)

        arg2 = Argument(name="arg2",
                        description=u"쎼 and 쎶 and <&> für",
                        validation="is_pos_int('some_name')",
                        data_type=Argument.data_type_number,
                        required_on_edit=True,
                        required_on_create=True,
                        title="Argument for ``test_scheme``")
        scheme.add_argument(arg2)

        constructed = scheme.to_xml()

        expected = ET.parse(
            data_open("data/scheme_without_defaults_and_argument_title.xml")
        ).getroot()
        self.assertEqual("Argument for ``test_scheme``", arg2.title)

        self.assertTrue(xml_compare(expected, constructed))
Ejemplo n.º 2
0
    def _do_scheme(self):
        scheme = Scheme(self.title)
        scheme.description = self.description
        scheme.use_external_validation = self.use_external_validation
        scheme.streaming_mode = Scheme.streaming_mode_xml
        scheme.use_single_instance = self.use_single_instance

        for argument in self.extra_arguments():
            name = argument['name']
            title = argument.get('title', None)
            description = argument.get('description', None)
            validation = argument.get('validation', None)
            data_type = argument.get('data_type', Argument.data_type_string)
            required_on_edit = argument.get('required_on_edit', False)
            required_on_create = argument.get('required_on_create', False)

            scheme.add_argument(
                Argument(name,
                         title=title,
                         description=description,
                         validation=validation,
                         data_type=data_type,
                         required_on_edit=required_on_edit,
                         required_on_create=required_on_create))

        return ET.tostring(scheme.to_xml())
Ejemplo n.º 3
0
    def test_generate_xml_from_scheme(self):
        """Checks that the XML generated by a Scheme object with all its fields set and
        some arguments added matches what we expect."""

        scheme = Scheme("abcd")
        scheme.description = u"쎼 and 쎶 and <&> für"
        scheme.streaming_mode = Scheme.streaming_mode_simple
        scheme.use_external_validation = "false"
        scheme.use_single_instance = "true"

        arg1 = Argument(name="arg1")
        scheme.add_argument(arg1)

        arg2 = Argument(
            name="arg2",
            description=u"쎼 and 쎶 and <&> für",
            validation="is_pos_int('some_name')",
            data_type=Argument.data_type_number,
            required_on_edit=True,
            required_on_create=True
        )
        scheme.add_argument(arg2)

        constructed = scheme.to_xml()
        expected = ET.parse(data_open("data/scheme_without_defaults.xml")).getroot()

        self.assertTrue(xml_compare(expected, constructed))
Ejemplo n.º 4
0
    def _do_scheme(self):
        scheme = Scheme(self.title)
        scheme.description = self.description
        scheme.use_external_validation = self.use_external_validation
        scheme.streaming_mode = Scheme.streaming_mode_xml
        scheme.use_single_instance = self.use_single_instance

        for argument in self.extra_arguments():
            name = argument["name"]
            title = argument.get("title", None)
            description = argument.get("description", None)
            validation = argument.get("validation", None)
            data_type = argument.get("data_type", Argument.data_type_string)
            required_on_edit = argument.get("required_on_edit", False)
            required_on_create = argument.get("required_on_create", False)

            scheme.add_argument(
                Argument(
                    name,
                    title=title,
                    description=description,
                    validation=validation,
                    data_type=data_type,
                    required_on_edit=required_on_edit,
                    required_on_create=required_on_create,
                )
            )

        return ET.tostring(scheme.to_xml(), encoding=SCHEME_ENCODING)
Ejemplo n.º 5
0
            def get_scheme(self):
                scheme = Scheme("abcd")
                scheme.description = u"\uC3BC and \uC3B6 and <&> f\u00FCr"
                scheme.streaming_mode = scheme.streaming_mode_simple
                scheme.use_external_validation = False
                scheme.use_single_instance = True

                arg1 = Argument("arg1")
                scheme.add_argument(arg1)

                arg2 = Argument("arg2")
                arg2.description = u"\uC3BC and \uC3B6 and <&> f\u00FCr"
                arg2.data_type = Argument.data_type_number
                arg2.required_on_create = True
                arg2.required_on_edit = True
                arg2.validation = "is_pos_int('some_name')"
                scheme.add_argument(arg2)

                return  scheme
            def get_scheme(self):
                scheme = Scheme("abcd")
                scheme.description = u"\uC3BC and \uC3B6 and <&> f\u00FCr"
                scheme.streaming_mode = scheme.streaming_mode_simple
                scheme.use_external_validation = False
                scheme.use_single_instance = True

                arg1 = Argument("arg1")
                scheme.add_argument(arg1)

                arg2 = Argument("arg2")
                arg2.description = u"\uC3BC and \uC3B6 and <&> f\u00FCr"
                arg2.data_type = Argument.data_type_number
                arg2.required_on_create = True
                arg2.required_on_edit = True
                arg2.validation = "is_pos_int('some_name')"
                scheme.add_argument(arg2)

                return scheme
Ejemplo n.º 7
0
def _build_scheme(title, use_single_instance, **kwargs):
    scheme = Scheme(title)
    scheme.description = kwargs.pop('description', None)
    scheme.use_external_validation = True
    scheme.streaming_mode = Scheme.streaming_mode_xml
    scheme.use_single_instance = use_single_instance
    for name, options in list(kwargs.pop('arguments', {}).items()):
        description = options.pop('description', None)
        validation = options.pop('validation', None)
        data_type = options.pop('data_type', Argument.data_type_string)
        required_on_edit = options.pop('required_on_edit', False)
        required_on_create = options.pop('required_on_create', False)
        title = options.pop('title', None)
        argument = Argument(
            name, description, validation, data_type,
            required_on_edit, required_on_create, title
        )
        scheme.add_argument(argument)

    return scheme