Exemple #1
0
def test_nested():
    Top = xmlfied('top', foo=Nested())
    Down = xmlfied('down', bar=Element(), baz=Attribute())

    d = Down(bar='123', baz='456')
    t = Top(foo=d)

    assert_that(
        etree.tostring(t.toxml()),
        string_contains_in_order('<top>', '<down', 'baz=', '"456"', '<bar>',
                                 '123', '</bar>', '</down>', '</top>'))
Exemple #2
0
class Environment(
        xmlfied('environment',
                namespace=COMMON_NAMESPACE,
                id=Element(),
                name=Element(),
                parameters=Many(Nested()))):
    pass
Exemple #3
0
def test_element_name():
    foo = xmlfied('foo', bar=Element(name='foo-bar'))

    assert_that(
        etree.tostring(foo(bar='123').toxml()),
        string_contains_in_order('<foo>', '<foo-bar>', '123', '</foo-bar>',
                                 '</foo>'))
Exemple #4
0
def test_bad_symbols_replacement():
    foo = xmlfied('foo', bar=Element(name='bar'))

    assert_that(
        etree.tostring(foo(bar=u'abОЛОЛОcd'.encode('cp1251')).toxml()),
        string_contains_in_order('<bar>', 'ab', '&#65533;' * 4, 'cd',
                                 '</bar>'))
Exemple #5
0
def test_attribute():
    AttrTest = xmlfied('attr_test', foo=Attribute())

    a = AttrTest(foo='bar')

    assert_that(etree.tostring(a.toxml()),
                string_contains_in_order('<attr_test', 'foo=', '"bar"', ">"))
Exemple #6
0
def test_many_nested():
    Item = xmlfied('item', value=Element())
    Box = xmlfied('box', items=WrappedMany(Nested()))

    box = Box(items=[])
    box.items.append(Item('a'))
    box.items.append(Item('a'))
    box.items.append(Item('a'))

    assert_that(
        etree.tostring(box.toxml()),
        all_of(
            string_contains_in_order('<box>', '<items>', '<item>', 'a',
                                     '</item>', '<item>', 'a', '</item>',
                                     '<item>', 'a', '</item>', '</items>',
                                     '</box>'), ))
Exemple #7
0
def test_optional():
    foo = xmlfied('foo', bar=Element().if_(lambda x: '123' not in x))

    assert_that(etree.tostring(foo(bar=' 123 ').toxml()),
                string_contains_in_order('<foo/>'))
    assert_that(etree.tostring(foo(bar=' 12 3').toxml()),
                string_contains_in_order('<foo>', '<bar>'))
Exemple #8
0
def test_element():
    ElementTest = xmlfied('element_test', ab=Element())

    a = ElementTest(ab='foo')
    assert_that(get_xml_string(a.toxml()), string_contains_in_order('<element_test>',
                                                                    '<ab>foo</ab>',
                                                                    '</element_test>'))
def test_nested():
    Top = xmlfied('top', foo=Nested())
    Down = xmlfied('down', bar=Element(), baz=Attribute())

    d = Down(bar='123', baz='456')
    t = Top(foo=d)

    assert_that(etree.tostring(t.toxml()), string_contains_in_order(
        '<top>',
        '<down',
        'baz=', '"456"',
        '<bar>',
        '123',
        '</bar>',
        '</down>',
        '</top>'
    ))
def test_many_nested():
    Item = xmlfied('item', value=Element())
    Box = xmlfied('box', items=Many(Nested()))

    box = Box(items=[])
    box.items.append(Item('a'))
    box.items.append(Item('a'))
    box.items.append(Item('a'))

    assert_that(etree.tostring(box.toxml()), all_of(
        string_contains_in_order('<box>',
                                 '<items>',
                                 '<item>', 'a', '</item>',
                                 '<item>', 'a', '</item>',
                                 '<item>', 'a', '</item>',
                                 '</items>',
                                 '</box>'),
    ))
Exemple #11
0
class TestStep(IterAttachmentsMixin,
               xmlfied('step',
                       name=Element(),
                       title=Element().if_(lambda x: x),
                       attachments=WrappedMany(Nested()),
                       steps=WrappedMany(Nested()),
                       start=Attribute(),
                       stop=Attribute(),
                       status=Attribute())):
    pass
def test_many_elements():
    Box = xmlfied('box', foos=Many(Element(name='foo')))

    box = Box(foos=['a', 'b', 'c'])

    assert_that(etree.tostring(box.toxml()), all_of(
        string_contains_in_order('<box>', '<foos>', '<foo>', 'a', '</foo>', '</foos>', '</box>'),
        string_contains_in_order('<box>', '<foos>', '<foo>', 'b', '</foo>', '</foos>', '</box>'),
        string_contains_in_order('<box>', '<foos>', '<foo>', 'c', '</foo>', '</foos>', '</box>')
    ))
Exemple #13
0
def test_many_elements():
    Box = xmlfied('box', foos=WrappedMany(Element(name='foo')))

    box = Box(foos=['a', 'b', 'c'])

    assert_that(get_xml_string(box.toxml()), all_of(
        string_contains_in_order('<box>', '<foos>', '<foo>', 'a', '</foo>', '</foos>', '</box>'),
        string_contains_in_order('<box>', '<foos>', '<foo>', 'b', '</foo>', '</foos>', '</box>'),
        string_contains_in_order('<box>', '<foos>', '<foo>', 'c', '</foo>', '</foos>', '</box>')
    ))
Exemple #14
0
class TestSuite(
        xmlfied('test-suite',
                namespace=ALLURE_NAMESPACE,
                name=Element(),
                title=Element().if_(lambda x: x),
                description=Element().if_(lambda x: x),
                tests=WrappedMany(Nested(), name='test-cases'),
                labels=WrappedMany(Nested()),
                start=Attribute(),
                stop=Attribute())):
    pass
Exemple #15
0
def test_elements_order():
    Foo = xmlfied('foo',
                  fields=[('bar', Element()), ('baz', Element()),
                          ('gaz', Element()), ('daz', Element())])

    foo = Foo(bar=3, baz=4, gaz=5, daz=6)

    assert_that(
        etree.tostring(foo.toxml()),
        string_contains_in_order('<bar>', '3', '</bar>', '<baz>', '4',
                                 '</baz>', '<gaz>', '5', '</gaz>', '<daz>',
                                 '6', '</daz>'))
def test_elements_order():
    Foo = xmlfied('foo', fields=[
        ('bar', Element()),
        ('baz', Element()),
        ('gaz', Element()),
        ('daz', Element())])

    foo = Foo(bar=3, baz=4, gaz=5, daz=6)

    assert_that(etree.tostring(foo.toxml()), string_contains_in_order(
        '<bar>', '3', '</bar>',
        '<baz>', '4', '</baz>',
        '<gaz>', '5', '</gaz>',
        '<daz>', '6', '</daz>'
    ))
Exemple #17
0
class TestCase(
        IterAttachmentsMixin,
        xmlfied(
            'test-case',
            id=Ignored(),  # internal field, see AllureTestListener
            name=Element(),
            title=Element().if_(lambda x: x),
            description=Element().if_(lambda x: x),
            failure=Nested().if_(lambda x: x),
            steps=WrappedMany(Nested()),
            attachments=WrappedMany(Nested()),
            labels=WrappedMany(Nested()),
            status=Attribute(),
            start=Attribute(),
            stop=Attribute())):
    pass
Exemple #18
0
'''
This holds allure report xml structures

Created on Oct 23, 2013

@author: pupssman
'''

from allure.rules import xmlfied, Attribute, Element, WrappedMany, Nested, Many
from allure.constants import ALLURE_NAMESPACE, COMMON_NAMESPACE

Attach = xmlfied('attachment',
                 source=Attribute(),
                 title=Attribute(),
                 type=Attribute())

Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace'))

TestCase = xmlfied('test-case',
                   name=Element(),
                   title=Element().if_(lambda x: x),
                   description=Element().if_(lambda x: x),
                   failure=Nested().if_(lambda x: x),
                   steps=WrappedMany(Nested()),
                   attachments=WrappedMany(Nested()),
                   labels=WrappedMany(Nested()),
                   status=Attribute(),
                   start=Attribute(),
                   stop=Attribute())

TestSuite = xmlfied('test-suite',
def test_optional():
    foo = xmlfied('foo', bar=Element().if_(lambda x: '123' not in x))

    assert_that(etree.tostring(foo(bar=' 123 ').toxml()), string_contains_in_order('<foo/>'))
    assert_that(etree.tostring(foo(bar=' 12 3').toxml()), string_contains_in_order('<foo>', '<bar>'))
def test_element_name():
    foo = xmlfied('foo', bar=Element(name='foo-bar'))

    assert_that(etree.tostring(foo(bar='123').toxml()), string_contains_in_order('<foo>', '<foo-bar>', '123', '</foo-bar>', '</foo>'))
def test_bad_symbols_replacement():
    foo = xmlfied('foo', bar=Element(name='bar'))

    assert_that(etree.tostring(foo(bar=u'abОЛОЛОcd'.encode('cp1251')).toxml()), string_contains_in_order('<bar>', 'ab', '&#65533;' * 4, 'cd', '</bar>'))
def test_illegal_xml_symbols():
    foo = xmlfied('foo', bar=Element(name='bar'))

    foo(bar=''.join(map(chr, range(128)))).toxml()
Exemple #23
0
class Failure(
        xmlfied('failure', message=Element(), trace=Element('stack-trace'))):
    """
def test_attribute():
    AttrTest = xmlfied('attr_test', foo=Attribute())

    a = AttrTest(foo='bar')

    assert_that(etree.tostring(a.toxml()), string_contains_in_order('<attr_test', 'foo=', '"bar"', ">"))
'''
This holds allure report xml structures

Created on Oct 23, 2013

@author: pupssman
'''

from allure.rules import xmlfied, Attribute, Element, Many, Nested
from allure.constants import ALLURE_NAMESPACE


Attach = xmlfied('attachment',
                 source=Attribute(),
                 title=Attribute(),
                 type=Attribute())


Failure = xmlfied('failure',
                  message=Element(),
                  trace=Element('stack-trace'))


TestCase = xmlfied('test-case',
                   name=Element(),
                   title=Element().if_(lambda x: x),
                   description=Element().if_(lambda x: x),
                   failure=Nested().if_(lambda x: x),
                   steps=Many(Nested()),
                   attachments=Many(Nested()),
                   labels=Many(Nested()),
Exemple #26
0
class EnvParameter(
        xmlfied('parameter', name=Element(), key=Element(), value=Element())):
    pass
Exemple #27
0
class TestLabel(xmlfied('label', name=Attribute(), value=Attribute())):
    pass
Exemple #28
0
class Attach(
        xmlfied('attachment',
                source=Attribute(),
                title=Attribute(),
                type=Attribute())):
    """
Exemple #29
0
'''
This holds allure report xml structures

Created on Oct 23, 2013

@author: pupssman
'''

from allure.rules import xmlfied, Attribute, Element, Many, Nested
from allure.constants import ALLURE_NAMESPACE

Attach = xmlfied('attachment',
                 source=Attribute(),
                 title=Attribute(),
                 type=Attribute())

Failure = xmlfied('failure', message=Element(), trace=Element('stack-trace'))

TestCase = xmlfied('test-case',
                   name=Element(),
                   title=Element().if_(lambda x: x),
                   description=Element().if_(lambda x: x),
                   failure=Nested().if_(lambda x: x),
                   steps=Many(Nested()),
                   attachments=Many(Nested()),
                   labels=Many(Nested()),
                   status=Attribute(),
                   start=Attribute(),
                   stop=Attribute(),
                   severity=Attribute())
Exemple #30
0
'''
This holds allure report xml structures

Created on Oct 23, 2013

@author: pupssman
'''

from allure.rules import xmlfied, Attribute, Element, WrappedMany, Nested, Many
from allure.constants import ALLURE_NAMESPACE, COMMON_NAMESPACE


Attach = xmlfied('attachment',
                 source=Attribute(),
                 title=Attribute(),
                 type=Attribute())


Failure = xmlfied('failure',
                  message=Element(),
                  trace=Element('stack-trace'))


TestCase = xmlfied('test-case',
                   name=Element(),
                   title=Element().if_(lambda x: x),
                   description=Element().if_(lambda x: x),
                   failure=Nested().if_(lambda x: x),
                   steps=WrappedMany(Nested()),
                   attachments=WrappedMany(Nested()),
                   labels=WrappedMany(Nested()),
Exemple #31
0
def test_illegal_xml_symbols():
    foo = xmlfied('foo', bar=Element(name='bar'))

    foo(bar=''.join(map(chr, range(128)))).toxml()