def __init__(self):
     self.objtype = ADTObjectType(
         None, None,
         XMLNamespace('mock',
                      'https://example.org/mock',
                      parents=[XMLNamespace('foo', 'bar')]),
         'application/xml', None, 'child')
class DummyWithChildFactory(ADTObject):

    OBJTYPE = ADTObjectType(
        'CODE', 'prefix/dummy',
        XMLNamespace('dummyxmlns', 'http://www.sap.com/adt/xmlns/dummy'),
        'application/vnd.sap.adt.test.elements.v2+xml',
        {'text/plain': 'source/main'}, 'dummyelem')

    def __init__(self):
        self._child = None
        self._child_setter = None

    @xml_element('child', factory=DummyChild)
    def child(self):
        return self._child

    @xml_element('child_setter', factory=DummyChild)
    def child_setter(self):
        get_logger().debug('Get instance')
        return self._child_setter

    @child_setter.setter
    def child_setter(self, value):
        get_logger().debug('Set instance')
        self._child_setter = value
class DummyADTCore(ADTObject):

    OBJTYPE = ADTObjectType(
        None, None, XMLNamespace('adtcore', 'http://www.sap.com/adt/core'),
        None, None, 'root')

    def __init__(self):
        super(DummyADTCore, self).__init__(None, None)
class Dummy(ADTObject):

    OBJTYPE = ADTObjectType(
        'CODE', 'prefix/dummy',
        XMLNamespace('dummyxmlns', 'http://www.sap.com/adt/xmlns/dummy'),
        'application/vnd.sap.adt.test.elements.v2+xml',
        {'text/plain': 'source/main'}, 'dummyelem')

    class Nested(metaclass=OrderedClassMembers):
        class SuperNested(metaclass=OrderedClassMembers):
            @xml_attribute('sup_nst_fst')
            def yetanother(self):
                return 'yetanother'

        @xml_attribute('nst_fst')
        def first(self):
            return 'nst_fst_val'

        @xml_attribute('nst_scn')
        def second(self):
            return 'nst_scn_val'

        @xml_element('child_nst')
        def supernested(self):
            return Dummy.Nested.SuperNested()

    def __init__(self):
        super(Dummy,
              self).__init__(None,
                             'dmtname',
                             metadata=ADTCoreData(package='testpkg',
                                                  description='Description',
                                                  language='CZ',
                                                  master_language='EN',
                                                  master_system='NPL',
                                                  responsible='FILAK'))

        self._nested = Dummy.Nested()

    @xml_attribute('attr_first')
    def first(self):
        return '11111'

    @xml_attribute('attr_second')
    def second(self):
        return '22222'

    @xml_attribute('attr_third', deserialize=False)
    def third(self):
        return '3333'

    @xml_element('first_elem')
    def value(self):
        return self._nested

    @xml_element('readonly_elem', deserialize=False)
    def readonly(self):
        return Dummy.Nested()
示例#5
0
文件: wb.py 项目: mnezerka/sapcli
    def objtype(self):
        """Monkey Patch ADTObject"""

        return ADTObjectType(None,
                             None,
                             XMLNamespace('ioc', 'http://www.sap.com/abapxml/inactiveCtsObjects'),
                             'application/vnd.sap.adt.inactivectsobjects.v1+xml',
                             None,
                             'inactiveObjects')
class DummyOjbectWithContainer(ADTObject):

    OBJTYPE = ADTObjectType(
        None, None, XMLNamespace('adtcore', 'http://www.sap.com/adt/core'),
        None, None, 'container')

    ContainerClass = XmlContainer.define('item', DummyContainerItem)

    def __init__(self):
        super(DummyOjbectWithContainer, self).__init__(None, None)

        self._items = DummyOjbectWithContainer.ContainerClass()

    @xml_element('items')
    def items(self):
        return self._items
class DummyContainer(ADTObject):

    OBJTYPE = ADTObjectType(
        None, None, XMLNamespace('adtcore', 'http://www.sap.com/adt/core'),
        None, None, 'container')

    def __init__(self):
        super(DummyContainer, self).__init__(None, None)

    @xml_element('item')
    def items(self):
        return [
            DummyContainerItem('1'),
            DummyContainerItem('2'),
            DummyContainerItem('3')
        ]
class DummyADTObjectWithVersions(ADTObject):

    OBJTYPE = ADTObjectType(
        None, None,
        XMLNamespace('mock', 'https://github.com/jfilak/sapcli/mock'), None,
        None, 'versioned')

    elemverfst = XmlNodeProperty('mock:elemverfst',
                                 kind=XmlElementKind.TEXT,
                                 version='V1')
    elemverboth = XmlNodeProperty('mock:elemverboth',
                                  kind=XmlElementKind.TEXT,
                                  version=['V1', 'V2'])

    attrverfst = XmlNodeAttributeProperty('mock:attrverfst', version='V1')
    attrverboth = XmlNodeAttributeProperty('mock:attrverboth',
                                           version=['V1', 'V2'])

    def __init__(self):
        super(DummyADTObjectWithVersions, self).__init__(None, None)

        self._elemverall = 'Init-elem-all'
        self.elemverfst = 'Init-elem-fst'
        self.elemverboth = 'Init-elem-both'

        self._attrverall = 'Init-attr-all'
        self.attrverfst = 'Init-attr-fst'
        self.attrverboth = 'Init-attr-both'

    @xml_element('mock:elemverall', kind=XmlElementKind.TEXT)
    def elemverall(self):
        return self._elemverall

    @elemverall.setter
    def elemverall(self, value):
        self._elemverall = value

    @xml_attribute('mock:attrverall')
    def attrverall(self):
        return self._attrverall

    @attrverall.setter
    def attrverall(self, value):
        self._attrverall = value
示例#9
0
文件: aunit.py 项目: corani/sapcli
"""ABAP Unit Test framework ADT wrappers"""

from typing import NamedTuple, List

import xml.sax
from xml.sax.handler import ContentHandler

from sap import get_logger
from sap.adt.objects import ADTObjectType, XMLNamespace
from sap.adt.annotations import OrderedClassMembers, XmlElementProperty, XmlNodeProperty, XmlNodeAttributeProperty
from sap.adt.marshalling import Marshal

XMLNS_AUNIT = XMLNamespace('aunit', 'http://www.sap.com/adt/aunit')


def mod_log():
    """ADT Module logger"""

    return get_logger()


# pylint: disable=too-few-public-methods
class CoverageOption(metaclass=OrderedClassMembers):
    """Enabled/Disabled coverage for an ABAP Unit Test run.

       Usage:
         run = RunConfiguration()
         run.external.coverage.active = 'false'
    """

    active = XmlNodeAttributeProperty('active', value='false')
class DummyWithSetters(ADTObject):

    OBJTYPE = ADTObjectType(
        'CODE', 'prefix/dummy',
        XMLNamespace('dummyxmlns', 'http://www.sap.com/adt/xmlns/dummy'),
        'application/vnd.sap.adt.test.elements.v2+xml',
        {'text/plain': 'source/main'}, 'dummyelem')

    class Nested(metaclass=OrderedClassMembers):
        class SuperNested(metaclass=OrderedClassMembers):
            def __init__(self):
                self._yetanother = None

            @xml_attribute('sup_nst_fst')
            def yetanother(self):
                return self._yetanother

            @yetanother.setter
            def yetanother(self, value):
                self._yetanother = value

        def __init__(self):
            self._child = DummyWithSetters.Nested.SuperNested()
            self._first = None
            self._second = None

        @xml_attribute('nst_fst')
        def first(self):
            return self._first

        @first.setter
        def first(self, value):
            self._first = value

        @xml_attribute('nst_scn')
        def second(self):
            return self._second

        @second.setter
        def second(self, value):
            self._second = value

        @xml_element('child_nst')
        def supernested(self):
            return self._child

    def __init__(self):
        super(DummyWithSetters,
              self).__init__(None,
                             'dmtname',
                             metadata=ADTCoreData(package='testpkg',
                                                  description='Description',
                                                  language='CZ',
                                                  master_language='EN',
                                                  master_system='NPL',
                                                  responsible='FILAK'))

        self._nested = DummyWithSetters.Nested()
        self._first = None
        self._second = None

    @xml_attribute('attr_first')
    def first(self):
        return self._first

    @first.setter
    def first(self, value):
        self._first = value

    @xml_attribute('attr_second')
    def second(self):
        return self._second

    @second.setter
    def second(self, value):
        self._second = value

    @xml_attribute('attr_third', deserialize=False)
    def third(self):
        return 'EEE'

    @xml_element('first_elem')
    def value(self):
        return self._nested

    @xml_element('readonly_elem', deserialize=False)
    def readonly(self):
        # If there is a bug in deserialization, the return None will reveal
        # that Marshal tried to modify read-only property
        return None
 def __init__(self):
     self.objtype = ADTObjectType(
         None, None, XMLNamespace('mock', 'https://example.org/mock'),
         'application/xml', None, 'withlist')
 def __init__(self):
     self.objtype = ADTObjectType(
         None, None, XMLNamespace('mock', 'https://example.org/mock'),
         'application/xml', None, 'have_child_with_text')
     self._text = 'content'
示例#13
0
文件: checks.py 项目: flaiker/sapcli
"""Object Checks ADT wrappers"""

from sap.adt.objects import ADTObjectType, XMLNamespace
from sap.adt.marshalling import Marshal
from sap.adt.annotations import OrderedClassMembers, XmlNodeAttributeProperty, XmlListNodeProperty, XmlElementKind, \
    XmlContainer

XMLNS_CHKRUN = XMLNamespace('chkrun', 'http://www.sap.com/adt/checkrun')


# pylint: disable=too-few-public-methods
class Reporter(metaclass=OrderedClassMembers):
    """ADT Object Checks Run Reporter"""

    name = XmlNodeAttributeProperty('chkrun:name')
    supported_types = XmlListNodeProperty('chkrun:supportedType',
                                          kind=XmlElementKind.TEXT)


# pylint: disable=invalid-name
ReportersContainer = XmlContainer.define('chkrun:reporter', Reporter)
ReportersContainer.objtype = ADTObjectType(
    None, 'checkruns/reporters', XMLNS_CHKRUN,
    'application/vnd.sap.adt.reporters+xml', None, 'checkReporters')


def fetch_reporters(connection):
    """Returns the list of supported ADT reporters"""

    reporters = ReportersContainer()
示例#14
0
"""ABAP Unit Test Coverage framework ADT wrappers"""
import xml
from typing import NamedTuple, List
from xml.sax.handler import ContentHandler

from sap import get_logger
from sap.adt.annotations import XmlNodeProperty, XmlElementProperty, OrderedClassMembers
from sap.adt.marshalling import Marshal
from sap.adt.objects import XMLNamespace, ADTObjectType

XMLNS_COV = XMLNamespace('cov', 'http://www.sap.com/adt/cov')


def mod_log():
    """ADT Module logger"""

    return get_logger()


# pylint: disable=too-few-public-methods
class Query(metaclass=OrderedClassMembers):
    """ABAP Coverage Query
    """

    objtype = ADTObjectType(None,
                            'runtime/traces/coverage/measurements/{identifier}',
                            XMLNS_COV,
                            'application/xml',
                            None,
                            'query')
示例#15
0
文件: wb.py 项目: mnezerka/sapcli
"""ABAP Workbench functionality"""

from sap.adt.objects import (XMLNamespace, ADTObjectType, OrderedClassMembers,
                             ADTObjectReferences, ADTObjectReference)

from sap.adt.annotations import xml_element, xml_attribute, xml_text_node_property, \
    XmlNodeAttributeProperty, XmlNodeProperty, XmlListNodeProperty
from sap.adt.marshalling import Marshal

from sap import get_logger
from sap.errors import SAPCliError


XMLNS_CHKL = XMLNamespace('chkl', 'http://www.sap.com/abapxml/checklis')


class IOCEntryData(metaclass=OrderedClassMembers):
    """Inactive Object or Transport"""

    def __init__(self, user='', linked=None, deleted=None):
        self._user = user
        self._linked = linked
        self._deleted = deleted
        self._reference = ADTObjectReference()

    @xml_element('ioc:ref')
    def reference(self):
        """Returns reference"""

        return self._reference
示例#16
0
文件: atc.py 项目: mnezerka/sapcli
import xml.sax
from xml.sax.handler import ContentHandler

from typing import NamedTuple

from sap import get_logger
from sap.adt.objects import OrderedClassMembers, ADTObjectType, XMLNamespace, xmlns_adtcore_ancestor
from sap.adt.annotations import xml_element, XmlNodeProperty, xml_text_node_property, XmlContainer, \
    XmlNodeAttributeProperty
from sap.adt.marshalling import Marshal
from sap.adt.datapreview import DataPreview

CUSTOMIZING_MIME_TYPE_V1 = 'application/vnd.sap.atc.customizing-v1+xml'

XMLNS_ATC = XMLNamespace('atc', 'http://www.sap.com/adt/atc')
XMLNS_ATCINFO = XMLNamespace('atcinfo', 'http://www.sap.com/adt/atc/info')
XMLNS_ATCWORKLIST = XMLNamespace('atcworklist',
                                 'http://www.sap.com/adt/atc/worklist')
XMLNS_ATCOBJECT = xmlns_adtcore_ancestor('atcobject',
                                         'http://www.sap.com/adt/atc/object')
XMLNS_ATCFINDING = XMLNamespace('atcfinding',
                                'http://www.sap.com/adt/atc/finding')


def mod_log():
    """Returns logger for this module"""

    return get_logger()